0

I am using msmtp to send an email to my email address whenever my server is started and I'd like to make the server send an email when it shuts down as well. I've tried writing a simple script (the script itself works properly) and linking it to /etc/rc0.d and /etc/rc6.d, but without any effect. How can I properly exectue that script on shutdown?

10
  • What is the contents of your script you are trying to run?
    – stumblebee
    Mar 12, 2018 at 20:09
  • echo "Server shutdown" | msmtp email@address Mar 12, 2018 at 20:14
  • Does your script change a file if you echo something to a file? How did you create the link, did you use the absolute or relative path ? Cheers.
    – mgerber
    Mar 12, 2018 at 20:25
  • That should be preceded with #!/bin/sh and the full path to msmtp needs to be specified.
    – stumblebee
    Mar 12, 2018 at 20:26
  • Forgot to add that. The script itself works, a similar script already sends me an email when the server boots up. The problem is most likely that the script gets executed too late into the shutdown process. Mar 12, 2018 at 20:29

0

You must log in to answer this question.

Browse other questions tagged .