Created
August 4, 2021 12:09
-
-
Save pbelskiy/ea7e11b93ce817648b07e75848b7c1ea to your computer and use it in GitHub Desktop.
systemd restart on failed and notify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
After=postgresql.service | |
[Service] | |
Type=simple | |
ExecStartPre=/bin/bash -c '(journalctl -n 5 --user-unit=%n | grep "Failed with result") && \ | |
(journalctl -n 50 --user-unit=%n | mailx -s "[systemd] %n failed" [email protected]) || \ | |
true' | |
ExecStart=/usr/bin/python3 /home/user/daemon.py | |
Environment=PYTHONUNBUFFERED=1 | |
Restart=on-failure | |
RestartSec=10s | |
[Install] | |
WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment