I have a bash script to restart a service that runs every 3am to guarantee that the service isn't crashed when users require it. However, I need to provide a simpler way for my partner (that isn't from IT area) to run this script when something go wrong.
Is there any way to configure this script to run when a email is sent to some address?
Absolutely!
In your /etc/aliases file, do this:
... where the email will be sent to
[email protected]
and the script you've written is the path above. The email and all the headers will be passed to thestdin
of your script which you can process as needed (look for password, etc.)If the MTA obeys a ~/.forward file, then you can have procmail process the incoming mail and run a script as soon as the message arrives.
See http://www.panix.com/~elflord/unix/procmail.html
For one of my accounts, I have the following ~/.procmailrc
Absolutely.
You need:
Based on the requirements, I would advise postfix as the MTA; it has built-in capabilities to execute scripts on message reception, plus easy to configure restrictions on mail reception and connectivity.
Of course, most sysadmins would just configure cron.