systemctl简单的使用

systemctl简单的使用

查看所有启动项

sudo systemctl list-unit-files

使用grep过滤一下开启的grep enabled
sudo systemctl list-unit-files | grep enabled

查看.service文件的路径,及内容

sudo systemctl status openresty.service

禁用开机启动:

sudo systemctl disable mongodb.service
sudo systemctl disable nginx.service
sudo systemctl disable redis-server.service

停止已经开启的服务:

sudo systemctl stop mongodb.service
sudo systemctl stop nginx.service
sudo systemctl stop redis-server.service

服务相关编写可参考 使用Systemd开机启动管理jar包一文