2015-10-12 76 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