Linux shell定時器


#!/bin/ksh #Delaytime=0 AlarmHandler() { echo "Get SIGALAM" KillSubProcs exit 14 } KillSubProcs() { #kill cbm echo "it's time out,kill cbm here" if [ $? -eq 0 ];then echo "Sub-processes killed." fi } SetTimer() { Delaytime=$1 echo $Delaytime if [ $Delaytime -ne 0 ];then sleep $Delaytime && kill -s 14 $$ & #CHPROCIDS="$CHPROCIDS $!" TIMERPROC=$! fi } UnsetTimer() { echo "Start to unset timer" kill $TIMERPROC } trap AlarmHandler 14 SetTimer 30 #CHPROCIDS="$CHPROCIDS $!" #wait $! sleep 40 UnsetTimer echo "ALL Done." exit 0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM