Source:
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet
https://wiki.ubuntu.com/SystemdForUpstartUsers
http://wiki.nginx.org/FedoraSystemdServiceFile
Start/stop/reload a service:
service foo start # or
systemctl start foo
service foo stop # or
systemctl stop foo
service foo restart # or
systemctl restart foo
Reload a service using reload signal:
service foo reload
See if service is running:
service foo status # or
systemctl status foo
See tree listing of all services:
systemctl status
See job log:
sudo journalctl -u foo -f
Enable a service (to start on boot):
systemctl enable foo
Disable a service:
systemctl disable foo
Service Definition Directory:
/lib/systemd/system/
Example Nginx Service: /lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Links:
https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Links:
https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/
No comments:
Post a Comment