레이블이 shell script인 게시물을 표시합니다. 모든 게시물 표시
레이블이 shell script인 게시물을 표시합니다. 모든 게시물 표시

2013년 12월 4일 수요일

중복 실행 방지 쉘 스크립트 (Duplicate Execution Prevention shell script)

check process id...



date=$(date +%y/%m/%d-%H:%M:%S)
pid=`ps -ef | grep "filename" | grep -v 'grep' | awk '{print $2}'`

if [ -z $pid ]
then
execute ....
else
echo $data "can not dual exec process!!!\r\n";
fi

2013년 9월 12일 목요일

쉡 스크립트(shell script) - 중복실행 방지(To avoid duplicate runs)

#load date
date=$(date +%y/%m/%d-%H:%M:%S)

#해당되는 프로세스 ID 읽어오기 (read process id with file name 'takeOriginImage.php').
pid=`ps -ef | grep "takeOriginImage.php" | grep -v 'grep' | awk '{print $2}'`

#프로세스ID가 있을 경우, 즉 실행 중일 경우, 메시지를 출력하고 종료.
#If the process ID - that means if it is running, a message and exit.
if [ -z $pid ]
then
  /usr/local/php/bin/php /home/jdk/takeOriginImage.php > /home/jdk/_log/takeOriginImage.txt
else
  echo $data "can not dual exec process!!!\r\n";
fi