标签:art ice sig pre nts multi top tar bash
/lib/systemd/system下创建test.service文件
vim /lib/systemd/system/test.service
[Unit] Description=Test [Service] #EnvironmentFile=/etc/systemd/test.conf ExecStart=/opt/test.sh ExecReload=/bin/kill -SIGHUP $MAINPID ExecStop=/bin/kill -SIGINT $MAINPID [Install] WantedBy=multi-user.target
创建test.sh
vim /opt/test.sh
#!/bin/bash while true do echo `date`,"ok" >>/tmp/test.log done
设置开机启动
systemctl enable test.service
显示
Created symlink /etc/systemd/system/multi-user.target.wants/test.service → /lib/systemd/system/test.service.
重启
reboot
重启后,看下/tmp/test.log的内容
vim /opt/test.log
标签:art ice sig pre nts multi top tar bash
原文地址:https://www.cnblogs.com/wintersoft/p/9937839.html