Remove old backups automatically over 86400 mins

Remove old backups automatically over 86400 mins when disk used over 90% & send mail to named E-mail. SERVER_NAME=`hostname` vvv=`df -h|awk -F ‘ ‘ ‘{print $5}’|tail -n1` len=${#vvv} newLen=$(( len – 1 )) num=${vvv:0:newLen} if [[ num -gt 90 ]]; then find /path/to/dir -name ‘*tar.gz’ -cmin +86400 -exec rm {} \; find /path/to/another/dir -name ‘*tar.gz’ […]

get.ip.source.sh

#!/bin/bash #writen by simon @20140325 filesource=mysql.log output=denied.ip`date ‘+%Y%m%d’` ipp (){ exec < $1 tring_times=0 while read a do columns=`echo $a|awk -F' ' '{print NF; exit}'` if [ ! $columns -eq '2' ];then continue fi sourceip=`echo $a |awk -F' ' '{print $2}'` ipcount=`echo $a|awk -F' ' '{print $1}'` sring=`curl -s "http://ip138.com/ips138.asp?ip=${sourceip}&action=2"| iconv -f gb2312 -t utf-8|grep […]

One shell

#!/bin/bash #auth:codewalker #mail:simon.xie@codewalker.me #do remote script ssh $host “ret=0” 2>&1 IS_admin_MODE=false C_MODE_FUNCTION_LISTS='[rwho][rusers][rhost][connect][rsu][rpasswd][rfinger][rwrite]’ A_MODE_FUNCTION_LISTS='[rhost][ausers][afinger][rlistusers]’ PING_COUNT=1 PING_TIMEOUT=1 HOST_LIST_FILE=’/tmp/host_list’ USER_LIST_FILE=’/tmp/user_list’ START_TIME=$(date +%s) function help(){ cat > $USER_LIST_FILE done #else # echo “can’t longin remote host.” #fi done echo “add all user [DONE]” unset t_hosts unset t_arr_hosts unset host unset t_users unset username } #connect mode function CONNECT_MODE() { […]

bash脚本之备份文件之拉回本地

#!/bin/bash LOGFILE=/path/to/your/log/file.log REMOTE=/path/to/remote/dir/ LOCAL=/path/to/local/dir REMOTEIP=x.x.x.x USERNAME=x.x.x.x PORT=xxx echo “CP remote dirs to local START at `date +%Y%m%d-%H:%M:%S`” >> $LOGFILE scp -rv -P $PORT $USERNAMEt@$REMOTEIP:$REMOTE`date +%Y%m%d` $LOCAL echo “CP remote dirs to local END at `date +%Y%m%d-%H:%M:%S`” >> $LOGFILE

Shell Programming

via :http://www.linuxsig.org/files/bash_scripting.html Shell Programming This section describes the fundamentals of bash shell programming and covers the following topics: Creating and running shell programs Using shell variables The importance of quotes The test command Conditional statements Iteration statements Functions Creating and Running Shell Programs Shell programs, or scripts, are just text files that contain one or […]