shell脚本示例,运行无限循环的shell脚本来检测拒绝列表上的用户是否登录到UNIX系统多于一次。
2018-02-26 14:54
976 查看
#! /bin/sh while true do who | cut -d " " -f1 | sort> old.txt sleep 3 who | cut -d " " -f1 | sort> new.txt comm old.txt new.txt -2 -3 >> logOneTime.txt comm old.txt new.txt -1 -3 > newLog.txt num=0 cat newLog.txt | while read line do if grep $line['-'] user.deny>/dev/null then if grep $line logOneTime.txt>/dev/null then fullName=`grep $line['-'] user.deny | cut -d "-" -f2` num=`expr $num + 1` echo -e "The user $fullName (on the denial list) has logged in more than once!\n" fi fi done if [ $num -eq 0 ] then echo -e "No user on the user.deny list has multiple logins\n" fi done while true do
相关文章推荐
- 利用Shell脚本来监控Linux系统的负载、CPU、内存、硬盘、用户登录数
- 案例:Shell脚本检测网站url是否正常运行
- Shell脚本实现检测进程是否正在运行
- shell脚本-统计系统用户登录,终端,做什么-002
- Shell脚本检测Tomcat是否正在运行
- 利用Shell脚本来监控Linux系统的负载、CPU、内存、硬盘、用户登录数
- shell脚本监控登录用户是否异常
- Shell脚本_创建系统用户,从一个用户列表文件(6.18重构)。
- Shell脚本实现检测进程是否正在运行
- Shell脚本定时备份清除运行系统日志的代码
- shell脚本实现某一进程是否运行结束的监控
- Ubuntu系统编写shell脚本程序一次安装多个软件包
- SHELL脚本:检测一坨IP是否都能ping通(网卡监控)
- Linux系统shell脚本判断变量文件目录:权限、是否存在、空值、相等
- 嵌入式 uboot启动中被用户终止后死循环到哪问题的解析,tstc检测是否存在标准输入流
- 通过进程检测服务时脚本文件名不要起要检测的服务名字命名 shell程序从上到下执行若定义函数或引用系统函数需先定义 kill -USR2
- python脚本检测linux进程是否运行
- shell脚本检测mysql是否启动的方法
- [JavaScript]用脚本检测用户是否把网站加入信任站点
- Linux系统shell脚本判断变量文件目录:权限、是否存在、空值、相等