#!/bin/bash #mwg@2012-4-4 banben=jx2ib qufu=101-4 gsnum=(1 2 3 4) ##定義變量####### if [ ${banben} = jx2 -o ${banben} = jx2ib ] then gs_path=/home/xmission/jxonline2/gs WORKDIR=/home/xmission/jxonline2/jx2tools/logarchive/ elif [ ${banben} = jx2wz ] then gs_path=/home/kingsoft/server/gameserver0 WORKDIR=/home/kingsoft/server/jx2tools/logarchive/ else echo "banben is error" exit fi usetime=$(date '-d 10 minutes ago' +%Y%m%d%H%M) tar_time=`date '+%Y%m%d-%H%M'` tim=`date '+%Y%m%d'` tmpdir=${WORKDIR}core_tmp/ ##定義ftp變量####### #FTP set FTPU='jx2uplog' FTPP='Dc6XV4Cz' FTPH='219.239.93.156' NCFTPPUT=${WORKDIR}ncftpput PDIR1=/${banben}/core/ ##每次執行此腳本生成一個心跳包並上傳########################### if [ ${#gsnum[@]} = 2 -a ${gsnum[0]} = 1 ] then Heartgs=gs1+gs2 elif [ ${#gsnum[@]} = 2 -a ${gsnum[0]} = 3 ] then Heartgs=gs3+gs4 else Heartgs=gs fi Heartbeatfile=${tmpdir}${banben}_${qufu}_${Heartgs}_Heartbeat.txt echo ${tar_time} > ${Heartbeatfile} if [ -f ${Heartbeatfile} ] then $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1}check/${tim} ${Heartbeatfile} fi ############################# [ -d ${tmpdir} ] || mkdir ${tmpdir} for i in ${gsnum[@]} do logfile=${qufu}_'gs'${i}core${tar_time}.txt ls -lt --time-style '+%Y%m%d%H%M' ${gs_path}${i} |grep -E 'core\.[0-9]+'|awk '{print $6,$7}' > ${tmpdir}${logfile} corefile_time=($(cat ${tmpdir}${logfile}|awk '{print $1}')) if [ ${#corefile_time[@]} -eq 0 ] then rm -rf ${tmpdir}${logfile} continue else corefile=($(cat ${tmpdir}${logfile}|awk '{print $2}')) #獲取並上傳core文件 o=0 for j in ${corefile_time[@]} do if [ ${j} -gt ${usetime} ] then o=$((o+1)) continue else cd ${gs_path}${i} && [ -f ${corefile[$o]} ] && mv ${corefile[$o]} ${tmpdir} tarfile=${qufu}_'gs'${i}_${corefile[$o]}_${j}.tar.gz cd ${tmpdir} && tar -zcvf ${tarfile} ${corefile[$o]} && rm -rf ${corefile[$o]} $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1} ${tmpdir}${tarfile} \ || $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1} ${tmpdir}${tarfile} \ || $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1} ${tmpdir}${tarfile} o=$((o+1)) fi done $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1}check/${tim} ${tmpdir}${logfile} \ || $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1}check/${tim} ${tmpdir}${logfile} \ || $NCFTPPUT -u$FTPU -p$FTPP -m -R -DD $FTPH ${PDIR1}check/${tim} ${tmpdir}${logfile} fi done exit 0
coredump.sh
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.