我想确保每次有人登录我的服务器时都收到一封电子邮件说:
ALERT Shell Access on:Tue Jun 16 11:04:10 CDT 2009 user123 pts/0 2009-06-16 11:04
所以我把这段代码:
echo 'ALERT Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" example@example.com
Run Code Online (Sandbox Code Playgroud)
在.bashrc.
为什么我没有收到任何电子邮件?
谢谢你的帮助,J
Sor*_*rin 11
当bash作为交互式非登录shell运行时执行.bashrc,而不是ssh时的情况.在.bash_profile中添加相同的代码,该代码应该在shell是登录shell时运行
注意:许多发行版从.bash_profile中获取.bashrc,我可能错了,问题可能不是关于.bashrc/.bash_profile