helloworld设置成开机自启动的服务

程序的工作目录:

helloworld设置成开机自启动的服务

涉及的几个文件:

helloworld设置成开机自启动的服务

程序源代码:

helloworld设置成开机自启动的服务

启动脚本和停止脚本的内容:

helloworld设置成开机自启动的服务

helloworld设置成开机自启动的服务

服务配置文件:

helloworld设置成开机自启动的服务

 

该服务启动后,具有异常退出后自动重启功能。

systemctl enable test :开机自动启动。

systemctl disable test:开机不自动启动。

systemctl start test :启动服务

systemctl stop test :停止服务

 

注意事项:

1.文件中设计的各种路径要正确无误。

2.脚本文件要增加可执行属性。

3.否者报错!