User Tools

Site Tools


linux:systemd

How to systemd

Set systemd log level to error. I don't like my log flooded by nonsense.

/etc/systemd/system.conf

LogLevel=crit

(emerg, alert, crit, err, warning, notice, info, debug)

Limit systemd journal by editing /etc/systemd/journald.conf

SystemMaxUse=10M

Commands

# systemctl <enable|disable|start|stop|restart|reload|status> service

nginx systemd sample script

Save this file as /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
LimitNOFILE=60000

[Install]
WantedBy=multi-user.target

RC-local Service

touch /etc/systemd/system/rc-local.service
systemctl enable rc-local

[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local

[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes

[Install]
 WantedBy=multi-user.target
linux/systemd.txt · Last modified: 2019/07/24 10:03 by Jan Forman