一、登录日志记录
vi /etc/profile
在最后面添加一行:
echo "`who`" > /var/log/login.log
二、监控日志文件
#!/bin/bash while true do sleep 2 a=`stat -c %Y /var/log/login.log` b=`date +%s` if [ $(($b-$a)) -le 10 ]; then echo "somebody login in!!!do something!!!" `执行命令` fi echo "every thing goes well, no login operate..." done