2015-10-12 73 views
0

我的cronjob執行多次。
我的設置是否錯誤?
請幫我爲什麼cronjob多次執行

這是腳本

#!/bin/bash 
source /home/obe/env/bin/activate 
cd /home/obe/env/crawl/pjt/pjt 
scrapy crawl gets 

這是我設置的crontab中,我使用centos7

* 23 * * * /home/obe/env/crawl/cron_set.sh 

,而且我用ps aux | grep cron 我發現我的cronjob執行許多時間

root  1202 0.0 0.0 126336 288 ?  Ss 17:16 0:02 /usr/sbin/crond -n 
root  9870 0.0 0.0 113116  8 ?  Ss 23:00 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  9908 0.0 0.0 113116  8 ?  Ss 23:01 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10203 0.0 0.0 113116  8 ?  Ss 23:09 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10238 0.0 0.0 113116  8 ?  Ss 23:10 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10269 0.0 0.0 113116  8 ?  Ss 23:11 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10328 0.0 0.0 113116  8 ?  Ss 23:13 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10370 0.0 0.0 113116  8 ?  Ss 23:14 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10412 0.0 0.0 113116  8 ?  Ss 23:15 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10455 0.0 0.0 113116  8 ?  Ss 23:16 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10594 0.0 0.0 113116  8 ?  Ss 23:17 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10631 0.0 0.0 113116  8 ?  Ss 23:18 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10660 0.0 0.0 113116  8 ?  Ss 23:19 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10699 0.0 0.0 113116  8 ?  Ss 23:20 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10731 0.0 0.0 113116  8 ?  Ss 23:21 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10753 0.0 0.0 113116  4 ?  Ss 23:22 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root  10779 0.0 0.0 113116 36 ?  Ss 23:23 0:00 /bin/bash /home/obe/env/clawer/cron_set.sh 
root 10802 0.5 0.0 112644 216 pts/2 S+ 23:23 0:00 grep --color=auto cron 

爲什麼會發生這種情況?

回答

0

你的crontab * 23 * * * /home/obe/env/crawl/cron_set.sh表示:

命令/home/obe/env/crawl/cron_set.sh將執行每分鐘每天晚上11點。

如果你想讓它在每天運行一次,它應該是:0 23 * * * /home/obe/env/crawl/cron_set.sh這意味着

命令/ home/obe/env/crawl/cron_set.sh將於每天晚上11點執行。

接下來的時間是指:http://www.cronchecker.net/

快樂crons

+0

thanks.But幾次,過程真的只執行一次,做喲知道爲什麼? – user2492364

+0

你的程序每11分鐘執行一次,而不是一次。 – cgon

+0

對不起,我混淆了。無視我所說的,你是對的。 – user2492364