6

I have a cron task as

6,36 * * * * python /usr/local/news.py >> /var/log/newlog

it is supposed to run at every 6th and 36th minute of each hour.

But for some how the system runs this task 4 processes/times each time. This task is to update database, and it causes problem when three processes updating database at the same time.

I have 4 tasks listing in /var/spool/cron/root, this is one of the tasks

What possibly went wrong here?

Thanks

Edit:

Oct 9 20:06:01 online CROND[7882]: (root) CMD (python /usr/local/news.py >> /var/log/newslog)  
Oct 9 20:06:01 online CROND[7883]: (root) CMD (python /usr/local/news.py >> /var/log/newslog)  
Oct 9 20:06:01 online CROND[7888]: (root) CMD (python /usr/local/news.py >> /var/log//newslog)  
Oct 9 20:06:01 online CROND[7890]: (root) CMD (python /usr/local/news.py >> /var/log//newslog)
8
  • What does your log say? Oct 10, 2009 at 2:02
  • I mean /var/log/cron.log rather than the one in the crontab line above. Oct 10, 2009 at 2:04
  • Oct 9 20:06:01 online CROND[7882]: (root) CMD (python /usr/local/news.py >> /var/log/newslog) Oct 9 20:06:01 online CROND[7883]: (root) CMD (python /usr/local/news.py >> /var/log/newslog) Oct 9 20:06:01 online CROND[7888]: (root) CMD (python /usr/local/news.py >> /var/log//newslog) Oct 9 20:06:01 online CROND[7890]: (root) CMD (python /usr/local/news.py >> /var/log//newslog)
    – Weiwei
    Oct 10, 2009 at 3:28
  • 4 lines of "Oct 9 20:06:01 online CROND[7890]: (root) CMD (python /usr/local/news.py >> /var/log//newslog)" running at the same time, now sure what is going on
    – Weiwei
    Oct 10, 2009 at 3:29
  • FYI: I have 4 tasks listing in /var/spool/cron/root
    – Weiwei
    Oct 10, 2009 at 3:49

3 Answers 3

1

What is the result of the following command? If there is more than one number listed then cron is running more than once which could cause this problem.

pgrep -l cron
3
  • 3674 crond 6335 crond 20785 crond 22084 crond
    – Weiwei
    Oct 10, 2009 at 14:27
  • i have this output when i run pgrep -l cron " 3674 crond 6335 crond 20785 crond 22084 crond " It looks i have 4 copies of crond are running at the same time?
    – Weiwei
    Oct 10, 2009 at 14:30
  • Thanks! i think problem should be gone (after i rebooted my server). For somehow I have 4 instances of crond running at the same time.
    – Weiwei
    Oct 10, 2009 at 14:41
1

By 'I have 4 tasks listing in /var/spool/cron/root', do you mean:

'I have 4 lines in root's crontab, all the same thing.'?

Please paste the output of 'crontab -l'. If it looks anything like:

6,36 * * * * python /usr/local/news.py >> /var/log/newlog
6,36 * * * * python /usr/local/news.py >> /var/log/newlog
6,36 * * * * python /usr/local/news.py >> /var/log/newlog
6,36 * * * * python /usr/local/news.py >> /var/log/newlog

That's definitely the problem :0

2
  • sorry, no i have for different tasks. the one 6,36 * * * * python /usr/local/news.py >> /var/log/newlog is only one of them
    – Weiwei
    Oct 10, 2009 at 4:15
  • In that case, you don't happen to have started 4 instances of crond somehow, have you? Is this the only task that runs 4 copies at the same time, or do all tasks do so? Also, please paste the output of 'crontab -l' into your question.
    – MikeyB
    Oct 10, 2009 at 4:23
1

It looks like two of the runs have a slightly different syntax. Could you check /etc/crontab and /etc/cron.d to check you don't have copies of the command there?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.