文章链接
脚本语言-shell-权限命令
面5笔5写一个shell脚本,执行中每隔5分钟检查指定的用户是否登录系统,用户名从命令行输入,如果指定的用户已经登录,则显示相关信息。
#!/bin/bash
while :
do
if w|sed '1'd|awk '{print $1}'|grep -qw "$1"
then
echo "用户$1 已经登录系统."
exit
fi
sleep 300
done