Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a task that should run each day in Ubuntu10.04. So I use crontab and copy the scripts of the task to the directory /etc/cron.daily.

Here is the my crontab:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
22 0    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
48 2    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 3    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

But I found that the task in /etc/cron.daily ran twice each day! I didn't know why so I added a script (mainly called pstree -a) in /etc/cron.daily to list all processes. And then I found that actually there were two cron sub-processes!

  |-cron
  |   |-cron
  |   |   |-(cron)
  |   |   `-sh -c test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
  |   |       `-run-parts --report /etc/cron.daily
  |   |           `-aa /etc/cron.daily/aa
  |   |               `-pstree -a
  |   `-cron
  |       |-(cron)
  |       `-sh -c root\011test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
  |           `-run-parts --report /etc/cron.daily
  |               `-aa /etc/cron.daily/aa
  |                   `-pstree -a

Does anyone know why cron runs twice here?

share|improve this question
    
That root\011test in the second process makes me think the crontab file is somehow corrupted. –  Oliver Salzburg Apr 3 '12 at 10:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.