linux自动启动服务器
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?
Linux服务器启动后,如何使它们自动向我或其他管理员发送电子邮件 ?
I did this by adding a crontab entry on each servers like
我是通过在每个服务器上添加一个crontab条目来做到这一点的
@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.
在此, @reboot
使重新引导后调用脚本。
For the usage of mailx, please check:
有关mailx的用法,请检查:
Sending Email Using mailx in Linux Through Internal SMTP
Sending Email from mailx Command in Linux Using Gmail’s SMTP
在Linux中使用Gmail的SMTP从mailx命令发送电子邮件
Also note that on Debian, Ubuntu, Linux Mint and others, you may need to install heirloom-mailx
instead of the default mailutil
.
另请注意,在Debian,Ubuntu,Linux Mint等上,您可能需要安装heirloom-mailx
而不是默认的mailutil
。
翻译自: https://www.systutorials.com/how-to-email-admins-automatically-after-a-linux-server-starts/
linux自动启动服务器