Created
March 3, 2017 08:20
-
-
Save mydreambei-ai/8f72b6e982b4d81362eacc822f346369 to your computer and use it in GitHub Desktop.
systemd OnFailure send mail
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
#http://unix.stackexchange.com/questions/314329/mailx-not-sending-email-when-run-as-a-systemd-service | |
systemd send mail is odd, using mail must set flag -vv | |
# shadowsocks.service | |
[Unit] | |
Description=The Postgresql Server Restful API | |
OnFailure=failure-email@%n.service | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/sslocal -c /etc/shadowsocks.json | |
ExecStop=/bin/kill ${MAINPID} | |
Restart=always | |
RestartSec=5s | |
[Install] | |
WantedBy=multi-user.target | |
#[email protected] | |
[Unit] | |
Description=OnFailure for %n | |
[Service] | |
Type=oneshot | |
ExecStart=/home/lmy/onfailure.sh %N | |
#onfailure.sh | |
#!/bin/sh | |
echo $1 | /usr/bin/mail -vv -s "monit" [email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment