create myservice.service file in /lib/systemd/system/
like this:
[Unit]
Description=CAN Bus bridge to Ethernet
After=syslog.target network.target
[Service]
Restart=always
ExecStart=/etc/init.d/startmyservice
[Install]
WantedBy=multi-user.target
save it
reload services:
# systemctl --system daemon-reload
see status:
# systemctl status myservice.service
start service:
# systemctl start myservice.service
stop service:
# systemctl stop myservice.service
restart service:
# systemctl restart myservice.service
at last, please enable your service to make it autostart
# systemctl enable myservice.service
You can see something at here:
http://beaglebone.cameon.net/home/autostarting-services
http://www.nunoalves.com/open_source/?p=308
英文实在不行了,上中文吧:
整个思路是这样的,先编写service文件,编写完成之后用systemctl start命令去启动一下,并用systemctl status看一下是否启动成功了。然后可以再试试停止和重启,如果这些都对的话就可以用systemctl enable命令让它自启动。重启试试,重启之后可以用systemctl status看看是否启动来,也可以直接用systemctl命令看看所有的service状态。
总之多使用systemctl status命令来调试你编写的service。