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?
root\011test
in the second process makes me think thecrontab
file is somehow corrupted.