I enabled systemd to load monit at startup
sudo systemctl enable monit
sudo systemctl restart monit
ps aux | grep monit
root 6843 0.0 0.2 112492 2948 ? Sl 18:19 0:00 /usr/bin/monit -c /etc/monit/monitrc
lookpla+ 6857 0.0 0.0 14212 1008 pts/0 S+ 18:21 0:00 grep --color=auto monit
But when I kill monit it doesn't start again:
sudo kill 6843
ps aux | grep monit
lookpla+ 6862 0.0 0.1 14212 1028 pts/0 S+ 18:23 0:00 grep --color=auto monit
Systemctl shows that monit is active but exited
sudo systemctl status monit.service
● monit.service - LSB: service and resource monitoring daemon Loaded: loaded (/etc/init.d/monit; generated; vendor preset: enabled) Drop-In: /etc/systemd/system/monit.service.d └─override.conf Active: active (exited) since Wed 2017-09-06 18:19:17 UTC; 4min 29s ago Docs: man:systemd-sysv-generator(8) Process: 6830 ExecStop=/etc/init.d/monit stop (code=exited, status=0/SUCCESS) Process: 6835 ExecStart=/etc/init.d/monit start (code=exited, status=0/SUCCESS) Main PID: 6843 (code=exited, status=0/SUCCESS) Sep 06 18:19:17 localhost systemd[1]: Stopped LSB: service and resource monitoring daemon. Sep 06 18:19:17 localhost systemd[1]: Starting LSB: service and resource monitoring daemon... Sep 06 18:19:17 localhost monit[6835]: * Starting daemon monitor monit Sep 06 18:19:17 localhost monit[6835]: ...done. Sep 06 18:19:17 localhost systemd[1]: monit.service: PID file /run/monit.pid not readable (yet?) after start: No such file or directory Sep 06 18:19:17 localhost systemd[1]: Started LSB: service and resource monitoring daemon.
Could you help me to set up systemd so it will restart monit after it has been killed?
I use ubuntu 17.04
sudo systemctl stop monit
orsudo systemctl start monit
respectively?Restart=always
option to the services section in your systemd service file, this will restart the program when not stopped by
systemctl stop` commandsudo systemctl edit monit.service
and then addedRestart=always
under [System] section and then restarted monit but it didnt help