How to email admins automatically after a Linux server starts?

Managing 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?

asked Jan 19, 2015 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

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

mailx man page

Also note that on Debian, Ubuntu, Linux Mint and others, you may need to install heirloom-mailx instead of the default mailutil.

answered Jan 19, 2015 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...