标签:
[datacenter@newftp ftpsite]$ cat chk_mediaserver.sh
#!/bin/bash
ps -ef |grep mediaserver |grep -v ‘grep‘
if [ $?!=0 ] ;then
/opt/app/tv189/services/ticketplatform/mediaserver/src/mediaserver
else
exit 0;
fi
[datacenter@newftp ftpsite]$ cat chk_mount.sh
#!/bin/bash
df -h |grep 192.168.74.162 |grep -v ‘grep‘
if [ $?!=0 ] ;then
mount -t nfs 192.168.74.162:/data/other/mpoint /data/other/mpoint
else
exit 0;
fi
[datacenter@newftp ftpsite]$ cat Logs_Backup.sh
#!/bin/bash
# Filename: Logs_Backup.sh
# Location: /opt/scripts
# NFS: mount -t nfs 192.168.51.110:/data1 /data/Logs_Backup
# runtime: 1:00 every day
# crontab: 0 1 * * * /bin/sh /opt/scripts/Logs_Backup.sh > /opt/scripts/Logs_Backup.log 2>&1
# script log: /opt/scripts/Logs_Backup.log
# +------------------------------------------------------+
# | Three days ago nginx_logs put 192.168.51.110:/data1/ |
# +------------------------------------------------------+
Times=$(date --date ‘3 days ago‘ +‘%Y%m%d‘)
Y=$(echo $Times | cut -b 1-4)
M=$(echo $Times | cut -b 5-6)
D=$(echo $Times | cut -b 7-8)
#Src_Log_Path=/usr/local/tysx/logs
Src_Log_Path=/data/tysx/logs
Dst_Log_Path=/data/Logs_Backup
SERVID=HTTPVod_73_51
/bin/mount -l -t nfs | grep ‘/data1 /data/Logs_Backup‘
declare remount=`echo $?`
if [ $remount == 0 ];then
/bin/date
echo "/data/other/mpoint Mount nornall"
else
/bin/ping 192.168.51.110 -c 1 -w 1
declare reconnect=`echo $?`
if [ $reconnect == 0 ];then
/bin/mount -t nfs 192.168.51.110:/data1 /data/Logs_Backup
/bin/date
echo "Mount mpoint again"
else
/bin/date
echo "192.168.51.110 off-line"
exit 1
fi
fi
#Check mount of mporint
/bin/mkdir -p $Dst_Log_Path/$Y/$M/$D
#/data/Logs_Backup/2014/09/15/
gzip -N $Src_Log_Path/$Y/$M/access_$Times.log && /bin/mv $Src_Log_Path/$Y/$M/access_$Times.log.gz $Dst_Log_Path/$Y/$M/$D/${SERVID}_access_$Times.log.gz && /bin/rm -rf $Src_Log_Path/$Y/$M/$D
[datacenter@newftp ftpsite]$ cat upload_comment.sh
#!/bin/bash
DATE=$(date -d ‘1 days ago‘ +%Y%m%d)
START_TIME=$(date -d ‘1 days ago‘ +%F)" 00:00:00"
END_TIME=$(date +%F)" 00:00:00"
FILE_NAME=‘comment_‘$DATE‘.txt‘
DIR=‘/shell/upload_comment‘
cd $DIR
echo $START_TIME
echo $END_TIME
mysql -u root PASSWORD << EOF1
use comment;
select * from cmm_comment_info_000001 where CreateTime BETWEEN "$START_TIME" and "$END_TIME" into outfile "$DIR/data/$FILE_NAME" fields terminated by "|";
EOF1
sed -i ‘s/\\N//g‘ $DIR/data/$FILE_NAME
ftp -v -n 192.168.40.125 << EOF2
user fuser 111111
binary
prompt
lcd ./data
put $FILE_NAME
close
bye
EOF2
rm -f ./data/*
[datacenter@newftp shell]$ cat OTTlog.sh
#!/bin/bash
LOGPATH="/data/ftpsite/DataCenter/ottlogs"
DSTPATH="/data/ftpsite/Backup"
DATA=$(/bin/date -d "5 days ago" +%Y%m%d)
if [ -d $LOGPATH/$DATA ];then
tar -zcf $DSTPATH/OTTLOG$DATA.tar.gz $LOGPATH/$DATA
fi
if [ -f $DSTPATH/OTTLOG$DATA.tar.gz ];then
rm -rf $LOGPATH/$DATA
fi
[datacenter@newftp shell]$ cat userlogin.sh
#!/bin/bash
Ntime=$(date -d "1 day ago" +"%Y%m%d")
dir1=/data/ftpsite/DataCenter
dir2=/data/ftpsite/DataCenter/tianyikankan
log=/data/ftpsite/shell/userlogin.log
file1="other_user_login_log_"$Ntime".txt"
file2="Client40_user_login_log_"$Ntime".txt"
file3="YiXiuBa_other_user_login_log_"$Ntime".txt"
num1=$(cat $dir1/$file1 |wc -l)
num2=$(cat $dir1/$file2 |wc -l)
num3=$(cat $dir2/$file3 |wc -l)
total=$((num1+num2+num3))
cat $dir1/$file2 >> $dir1/$file1
cat $dir2/$file3 >> $dir1/$file1
#put_data(){
# /usr/bin/ftp -v -n 192.168.32.234 << END
# user fuser 111111
# binary
# lcd $dir1
# cd /temp
# put $file1
# bye
#END
#}
new_total=$(cat $dir1/$file1 |wc -l)
if [ $total == $new_total ];then
echo "-------------------" >> $log
echo "$Ntime:Completed!" >> $log
echo "Old_Total:$total" >> $log
echo "New_Total:$new_total" >> $log
# put_data
else
echo "-------------------" >> $log
echo "$Ntime:Error!" >> $log
echo "Old_Total:$total" >> $log
echo "New_Total:$new_total" >> $log
fi;
标签:
原文地址:http://www.cnblogs.com/lubing666666/p/4453870.html