编写systemd下服务脚本

编写systemd下服务脚本

一、在/lib/systemd/system目录下建立服务脚本

sshd.service 必须以service结尾

二、填写内容

[Unit]

Description=SSH Key Generation

 

[Service]

Type=oneshot

RemainAfterExit=yes

 

ExecStart=/etc/init.d/sshd  start

 

[Install]

WantedBy=multi-user.target

 

三、根据脚本后面的WantedBy=multi-user.target

在对于路径建立链接

Cd   /etc/systemd/system/multi-user.target.wants

Ln -s  /etc/systemd/system/multi-user.target.wants/sshd.service   sshd.service

 

posted on 2018-09-08 13:45  紫枫术河  阅读(243)  评论(0)    收藏  举报

导航