加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

SHELL训练营--day22_shell练习51-55

发布时间:2020-12-15 23:02:39 所属栏目:安全 来源:网络整理
导读:#判断网站运行 #!/bin/bash url="http://www.baidu.com/index.php" [email?protected] code=`curl -I $url 2/tmp/curl.err|head -1|awk ‘{print $2}‘` if [ -z "$code" ] then python mail.py $mail_user "$url 访问异常" "`cat /tmp/curl.err`" elif [ $c
#判断网站运行 #!/bin/bash url="http://www.baidu.com/index.php" [email?protected] code=`curl -I $url 2>/tmp/curl.err|head -1|awk ‘{print $2}‘` if [ -z "$code" ] then python mail.py $mail_user "$url 访问异常" "`cat /tmp/curl.err`" elif [ $code != "200" ] then curl -I $url &>/tmp/curl.log python mail.py $mail_user "$url访问异常,状态码$code" "`cat /tmp/curl.log`" fi #小于5k文件打包 #!/bin/bash t=`date +%F` cd $HOME tar czf $t.tar.gz `find ./ -type f -size -5k|xargs` #监控22端口是否被封 #!/bin/bash iptables -nvL INPUT --line-numbers |grep -w ‘dpt:22‘ |awk ‘$4 ~/REJECT|DROP/ {print $1}‘ >/tmp/iptables.log n=`wc -l /tmp/iptables.log` if [ $n -gt 0 ] then for n in `tac /tmp/iptables.log` do iptables -D INPUT $n done fi #分析日志 #!/bin/bash export LANG=en log="/usr/local/nginx/logs/access.log" t=`date +%d/%b/%Y:1[01]:[0-5][0-9]:` egrep "$t" $log| awk ‘{print $1}‘ |sort -n |uniq -c |sort -n |tail -1 |awk ‘{print $2}‘ #打印数字 #!/bin/bash read -p "Please input a number:" n n1=`echo $n |sed ‘s/[0-9]//g‘` if [ -n "$n1" ] then echo "Please input a number." exit fi for i in `seq 1 $n` do echo $i done read -p "If continue? y/n" c case $c in n|N) exit ;; y|Y) read -p "Please input a number:" n2 n3=`echo $2 |sed ‘s/[0-9]//g‘` if [ -n "$n3" ] then echo "Please input a number." exit fi if [ $n2 -le $n ] then echo "$n2 should grater than $n." exit fi for i in `seq $[$n+1] $n2` do echo $i done ;; *) echo "Please input a number." ;; esac

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读