User Tools

Site Tools


linux:systemd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
linux:systemd [2022/02/14 11:00] – [RC-local Service] Jan Formanlinux:systemd [2022/02/14 13:14] (current) – [RC-local Service] Jan Forman
Line 1: Line 1:
 +====== How to systemd ======
 +
 +Set systemd log level to error. I don't like my log flooded by nonsense.
 +
 +/etc/systemd/system.conf
 +<code>LogLevel=crit</code>
 +(emerg, alert, crit, err, warning, notice, info, debug)
 +
 +Limit systemd journal by editing
 +/etc/systemd/journald.conf
 +<code>SystemMaxUse=10M</code>
 +
 +===== Commands =====
 +<code># systemctl <enable|disable|start|stop|restart|reload|status> service</code>
 +<code># systemctl reset-failed service</code>
 +
 +===== nginx systemd sample script =====
 +Save this file as /lib/systemd/system/nginx.service
 +<code>
 +[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
 +</code>
 +
 +
 +===== RC-local Service =====
 +touch /etc/systemd/system/rc-local.service\\
 +systemctl enable rc-local
 +<code>
 +[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
 +</code>
 +
 +===== Check service security =====
 +<code>systemd-analyze security nginx.service</code>
  
linux/systemd.txt · Last modified: 2022/02/14 13:14 by Jan Forman