* If crontab is installed or can be installed on your system, USE CRONTAB!
Usage
$ ./timer_start.sh [start | stop | restart]
timer_start.sh
#!/bin/bash
start() {
nohup ./timer.sh & echo "timer start!"
}
stop() {
# pkill이 없을경우
# ./pkill.sh timer.sh & sleep 0
pkill -kill timer.sh
}
restart() {
stop
start
}
if [ -z "$1" ]
then
echo "Usage: ./timer_start.sh [start | stop | restart]"
else
$1
fi
timer.sh
#!/bin/bash #간단한 타이머 #if [ -z "$1" ] #then #echo "Usage: ./timer.sh [run/stop/restart]" #exit 1 #fi #$1 PRV=`date +%H%M%S` while [ 1 ] do sleep 1 #DAT=`date +%Y%m%d-%H%M%S` NOW=`date +%H%M%S` #echo $NOW if [ $NOW -ne $PRV ] then PRV=$NOW case $NOW in # 이 부분을 수정 # example # 20시42분00초에 test.sh 실행 # 10시00분00초에 test.sh 프로세스 kill, test.sh 실행 # *) 부분은 제거하지말것 043600 ) ./test.sh;; 100000 ) ./pkill.sh test.sh ./test.sh;; * ) ;; esac fi done
No comments:
Post a Comment