我想在系统即将关闭时向电子邮件 ID 发送电子邮件。我有 CentOS 6.4。下面是我的脚本。
cat /ect/init.d/sendshtmail
#!/bin/bash
EMAIL="example@example.com"
SHUTDOWNSUBJECT="["`hostname`"] - System Shutdown"
SHUTDOWNBODY="This is an automated message to notify you that "`hostname`" is shutting down.
LOCKFILE=/var/lock/subsys/SystemEmail
echo "${SHUTDOWNBODY}" | mutt -s "${SHUTDOWNSUBJECT}" ${EMAIL}
它具有适当的权限。手动运行它时,它运行良好。我刚刚将它符号链接到 /etc/rc0.d/ 文件夹。通过发出以下命令。
ln -s /etc/init.d/sendshtmail /etc/rc0.d/K00sendshtmail
但是脚本在关机期间没有发送任何电子邮件。提前致谢。