日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

  1. Dos 攻擊防范(自動屏蔽攻擊 IP)
#!/bin/bashDATE=$(date +%d/%b/%Y:%H:%M)LOG_FILE=/usr/local/nginx/logs/demo2.access.logABNORMAL_IP=$(tail -n5000 $LOG_FILE |grep $DATE |awk '{a[$1]++}END{for(i in a)if(a[i]>10)print i}')for IP in $ABNORMAL_IP; do    if [ $(iptables -vnL |grep -c "$IP") -eq 0 ]; then        iptables -I INPUT -s $IP -j DROP        echo "$(date +'%F_%T') $IP" >> /tmp/drop_ip.log    fidone

登錄后復(fù)制

  1. Linux 系統(tǒng)發(fā)送告警腳本
# yum install mailx# vi /etc/mail.rcset from=baojingtongzhi@163.com smtp=smtp.163.comset smtp-auth-user=baojingtongzhi@163.com smtp-auth-password=123456set smtp-auth=login

登錄后復(fù)制

  1. MySQL 數(shù)據(jù)庫備份單循環(huán)
#!/bin/bashDATE=$(date +%F_%H-%M-%S)HOST=localhostUSER=backupPASS=123.comBACKUP_DIR=/data/db_backupDB_LIST=$(mysql -h$HOST -u$USER -p$PASS -s -e "show databases;" 2>/dev/null |egrep -v "Database|information_schema|mysql|performance_schema|sys")for DB in $DB_LIST; do    BACKUP_NAME=$BACKUP_DIR/${DB}_${DATE}.sql    if ! mysqldump -h$HOST -u$USER -p$PASS -B $DB > $BACKUP_NAME 2>/dev/null; then        echo "$BACKUP_NAME 備份失敗!"    fidone

登錄后復(fù)制

  1. MySQL 數(shù)據(jù)庫備份多循環(huán)
#!/bin/bashDATE=$(date +%F_%H-%M-%S)HOST=localhostUSER=backupPASS=123.comBACKUP_DIR=/data/db_backupDB_LIST=$(mysql -h$HOST -u$USER -p$PASS -s -e "show databases;" 2>/dev/null |egrep -v "Database|information_schema|mysql|performance_schema|sys")for DB in $DB_LIST; do    BACKUP_DB_DIR=$BACKUP_DIR/${DB}_${DATE}    [ ! -d $BACKUP_DB_DIR ] && mkdir -p $BACKUP_DB_DIR &>/dev/null    TABLE_LIST=$(mysql -h$HOST -u$USER -p$PASS -s -e "use $DB;show tables;" 2>/dev/null)    for TABLE in $TABLE_LIST; do        BACKUP_NAME=$BACKUP_DB_DIR/${TABLE}.sql        if ! mysqldump -h$HOST -u$USER -p$PASS $DB $TABLE > $BACKUP_NAME 2>/dev/null; then            echo "$BACKUP_NAME 備份失敗!"        fi    donedone

登錄后復(fù)制

  1. Nginx 訪問訪問日志按天切割 關(guān)注Linux中文社區(qū)
#!/bin/bashLOG_DIR=/usr/local/nginx/logsYESTERDAY_TIME=$(date -d "yesterday" +%F)LOG_MONTH_DIR=$LOG_DIR/$(date +"%Y-%m")LOG_FILE_LIST="default.access.log"for LOG_FILE in $LOG_FILE_LIST; do    [ ! -d $LOG_MONTH_DIR ] && mkdir -p $LOG_MONTH_DIR    mv $LOG_DIR/$LOG_FILE $LOG_MONTH_DIR/${LOG_FILE}_${YESTERDAY_TIME}donekill -USR1 $(cat /var/run/nginx.pid)

登錄后復(fù)制

  1. Nginx 訪問日志分析腳本
#!/bin/bash# 日志格式: $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"LOG_FILE=$1echo "統(tǒng)計(jì)訪問最多的10個(gè)IP"awk '{a[$1]++}END{print "UV:",length(a);for(v in a)print v,a[v]}' $LOG_FILE |sort -k2 -nr |head -10echo "----------------------"echo "統(tǒng)計(jì)時(shí)間段訪問最多的IP"awk '$4>="[01/Dec/2018:13:20:25" && $4<="[27/Nov/2018:16:20:49"{a[$1]++}END{for(v in a)print v,a[v]}' $LOG_FILE |sort -k2 -nr|head -10echo "----------------------"echo "統(tǒng)計(jì)訪問最多的10個(gè)頁面"awk '{a[$7]++}END{print "PV:",length(a);for(v in a){if(a[v]>10)print v,a[v]}}' $LOG_FILE |sort -k2 -nrecho "----------------------"echo "統(tǒng)計(jì)訪問頁面狀態(tài)碼數(shù)量"awk '{a[$7" "$9]++}END{for(v in a){if(a[v]>5)print v,a[v]}}'

登錄后復(fù)制

  1. 查看網(wǎng)卡實(shí)時(shí)流量腳本
#!/bin/bashNIC=$1echo -e " In ------ Out"while true; do    OLD_IN=$(awk '$0~"'$NIC'"{print $2}' /proc/net/dev)    OLD_OUT=$(awk '$0~"'$NIC'"{print $10}' /proc/net/dev)    sleep 1    NEW_IN=$(awk  '$0~"'$NIC'"{print $2}' /proc/net/dev)    NEW_OUT=$(awk '$0~"'$NIC'"{print $10}' /proc/net/dev)    IN=$(printf "%.1f%s" "$((($NEW_IN-$OLD_IN)/1024))" "KB/s")    OUT=$(printf "%.1f%s" "$((($NEW_OUT-$OLD_OUT)/1024))" "KB/s")    echo "$IN $OUT"    sleep 1done

登錄后復(fù)制

  1. 服務(wù)器系統(tǒng)配置初始化腳本 另外,搜索公眾號Linux就該這樣學(xué)后臺回復(fù)“Linux”,獲取一份驚喜禮包。
#/bin/bash# 設(shè)置時(shí)區(qū)并同步時(shí)間ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtimeif ! crontab -l |grep ntpdate &>/dev/null ; then    (echo "* 1 * * * ntpdate time.windows.com >/dev/null 2>&1";crontab -l) |crontabfi# 禁用selinuxsed -i '/SELINUX/{s/permissive/disabled/}' /etc/selinux/config# 關(guān)閉防火墻if egrep "7.[0-9]" /etc/redhat-release &>/dev/null; then    systemctl stop firewalld    systemctl disable firewalldelif egrep "6.[0-9]" /etc/redhat-release &>/dev/null; then    service iptables stop    chkconfig iptables offfi# 歷史命令顯示操作時(shí)間if ! grep HISTTIMEFORMAT /etc/bashrc; then    echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/bashrcfi# SSH超時(shí)時(shí)間if ! grep "TMOUT=600" /etc/profile &>/dev/null; then    echo "export TMOUT=600" >> /etc/profilefi# 禁止root遠(yuǎn)程登錄sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config# 禁止定時(shí)任務(wù)向發(fā)送郵件sed -i 's/^MAILTO=root/MAILTO=""/' /etc/crontab# 設(shè)置最大打開文件數(shù)if ! grep "* soft nofile 65535" /etc/security/limits.conf &>/dev/null; then    cat >> /etc/security/limits.conf << EOF    * soft nofile 65535    * hard nofile 65535EOFfi# 系統(tǒng)內(nèi)核優(yōu)化cat >> /etc/sysctl.conf << EOFnet.ipv4.tcp_syncookies = 1net.ipv4.tcp_max_tw_buckets = 20480net.ipv4.tcp_max_syn_backlog = 20480net.core.netdev_max_backlog = 262144net.ipv4.tcp_fin_timeout = 20EOF# 減少SWAP使用echo "0" > /proc/sys/vm/swappiness# 安裝系統(tǒng)性能分析工具及其他yum install gcc make autoconf vim sysstat net-tools iostat if

登錄后復(fù)制

  1. 監(jiān)控 100 臺服務(wù)器磁盤利用率腳本
#!/bin/bashHOST_INFO=host.infofor IP in $(awk '/^[^#]/{print $1}' $HOST_INFO); do    USER=$(awk -v ip=$IP 'ip==$1{print $2}' $HOST_INFO)    PORT=$(awk -v ip=$IP 'ip==$1{print $3}' $HOST_INFO)    TMP_FILE=/tmp/disk.tmp    ssh -p $PORT $USER@$IP 'df -h' > $TMP_FILE    USE_RATE_LIST=$(awk 'BEGIN{OFS="="}/^\/dev/{print $NF,int($5)}' $TMP_FILE)    for USE_RATE in $USE_RATE_LIST; do        PART_NAME=${USE_RATE%=*}        USE_RATE=${USE_RATE#*=}        if [ $USE_RATE -ge 80 ]; then            echo "Warning: $PART_NAME Partition usage $USE_RATE%!"        fi    donedone

登錄后復(fù)制

以上就是9 個(gè)實(shí)用 shell 腳本,建議收藏!的詳細(xì)內(nèi)容,更多請關(guān)注www.92cms.cn其它相關(guān)文章!

分享到:
標(biāo)簽:shell 實(shí)用 建議 收藏 腳本
用戶無頭像

網(wǎng)友整理

注冊時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定