分类: LINUX
2011-10-28 10:39:41
################################################################# # #互斥运行 # ################################################################# mutex_Run() { if [ -e /tmp/spg_export_log_tmp.sh ];then rm -f /tmp/spg_export_log_tmp.sh >> ${LOG_FILE} 2>&1; fi #看到这个变量中的进程存在就停一会再运行 mutex_FileName="spg_autoexport_log.sh" while : do process=`ps -ef |grep "$mutex_FileName" |grep -v grep` if [ "${process}" == "" ];then break; echo "`date +%Y-%m-%d\ %H:%M:%S` ok now start runing the script to export log " >> ${LOG_FILE} 2>&1; else echo "$process" >> ${LOG_FILE} 2>&1; echo "`date +%Y-%m-%d\ %H:%M:%S` spg_export_log.sh is runing other script ,and sleep 3 second. " >> ${LOG_FILE} 2>&1; echo ' #!/bin/sh mutex_FileName_tmp="spg_autoexport_log.sh" while : do process_tmp=`ps -ef |grep "$mutex_FileName" |grep -v grep`; if [ "${process_tmp}" == "" ];then sh /opt/SPG2800/util/log_export/spg_export_log.sh; echo "`date +%Y-%m-%d\ %H:%M:%S` spg_export_log.sh start rung...... " >> ${LOG_FILE} 2>&1; exit 0; else echo "`date +%Y-%m-%d\ %H:%M:%S`the process_tmp=$process_tmp"........ >> ${LOG_FILE} 2>&1; echo "`date +%Y-%m-%d\ %H:%M:%S` spg_export_log.sh is runing other script ,and sleep 3 second. " >> ${LOG_FILE} 2>&1; sleep 3; fi ' >/tmp/spg_export_log_tmp.sh if [ -e /tmp/spg_export_log_tmp.sh ];then sh /tmp/spg_export_log_tmp.sh >> ${LOG_FILE} 2>&1; fi exit 1; fi done } |