- 論壇徽章:
- 0
|
- #!/bin/bash
- runtime="0800,1200,1600,2200" #do some command at these time
- yesterday=
- i=0
- while [ 1 ]
- do
- curtime=$(date +%H%M)
- [ "X$runtime" == "X${runtime/$curtime}" ] && sleep 10 && continue #do nothing
- today=$(date +%Y%m%d)
- [ "X$today" != "X$yesterday"] && i=0 && yesterday=$today
- ((i++))
- #do some command
- [ $i -eq 1 ] && #do command a
- #do some command
- if [ ${runtime##*,} == $curtime ] ;then
- #do command b
- #do some command
- [ $(date +%w) -eq 0 ] && #do command c at sunday (7=0)
- fi
- [ $(date +%H%M) == $curtime ] && sleep 60 #run once at a time
- done
復(fù)制代碼
然后運(yùn)行這個(gè)腳本就可以了,不需要用cron
可以適當(dāng)調(diào)整sleep 的時(shí)間,取決于腳本運(yùn)行的時(shí)間
[ 本帖最后由 springwind426 于 2007-12-6 16:32 編輯 ] |
|