CentOS 7如何添加自定义系统服务?

Centos7开机启动项分为system和user两种类型

比如像mysql这种不用登陆就可以运行的就是system型,放在/usr/lib/systemd/system下,反之,用户登录后才能运行的程序,存在用户(user)里。

假如我自定义了一个系统服务,叫mytest.server,文件格式可参考system目录下的其他文件。

执行 systemctl enable mytest.service 设置开机自启动

systemctl start mytest.service 启动服务

systemctl status mytest.service 查看状态

查看开机项

systemctl list-unit-files