How to email admins automatically after a Linux server starts?
Posted on In QAManaging a cluster of servers, I would like to notified when a server is started.
How to make the Linux servers email me or other admins automatically after they are started?
I did this by adding a crontab entry on each servers like
@reboot date | mailx -S smtp=smtp://smtp.example.com -s "`hostname` started" -r zma@example.com zma@example.com
Here, @reboot
makes the script invoked after reboot.
For the usage of mailx, please check:
Sending Email Using mailx in Linux Through Internal SMTP
Sending Email from mailx Command in Linux Using Gmail’s SMTP
Also note that on Debian, Ubuntu, Linux Mint and others, you may need to install heirloom-mailx
instead of the default mailutil
.