linux 用户管理&进程管理

查看超过一天的进程 (这里需要排除掉root和一些特定的进程):
ps aux | grep -v root |grep -v PID|grep -v ntp | grep -v rpc | grep -v nobody| grep -v tmux|grep -v SCREEN | awk '$9 !~ /[0-9]:[0-9]/'
杀掉超过一天的进程 (这里需要排除掉root和一些特定的进程):
ps aux | grep -v root |grep -v PID|grep -v ntp | grep -v rpc | grep -v nobody| grep -v tmux|grep -v SCREEN  | awk '$9 !~ /[0-9]:[0-9]/' | awk '{print $2}'| xargs kill -9
查看空闲超过一天的用户
w | grep days | grep pts
强制断开登录空闲超过一天的用户
w | grep days | grep pts | awk '{print "/dev/"$2}' | xargs sudo fuser -k
查看登录超过一天的用户
w | awk '$4 !~ /[0-9]:[0-9]/' | grep -v IDLE | grep -v users
关闭登录超过一天的用户
w | awk '$4 !~ /[0-9]:[0-9]/' | grep -v IDLE | grep -v users |awk '{print "/dev/"$2}'| xargs fuser -k

发表评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.