[CentOS] Scheduling tasks using cron...

Jose Alburquerque jaalburquerque at cox.net
Mon Jan 9 16:25:43 UTC 2006



Peter Arremann wrote:

>Looks good to me... are you sure you have permissions for the output file to 
>be written? Is cron running? what is the output from /var/log/cron for that 
>timeframe?
>  
>
Actually, by looking at the log (thanks for the info, I did not know!).  
I see that I booted my system on 1/8/2006 around 8:30pm and kept it up 
until 1:00am on 1/9/2006.  I was experimenting with two Gui's for 
crontab (gnome-schedule and gnome-crontab) and now I can see that some 
test processes did execute (ie. the ls > /dev/null commands, which, of 
course did not provide any output so that I did not know if they executed!).

Here's the /var/log/cron entries for the relevant times:

Jan  8 22:39:20 sweety crond[3794]: (CRON) STARTUP (V5.0)
Jan  8 22:39:21 sweety anacron[3830]: Anacron 2.3 started on 2006-01-08
Jan  8 22:39:21 sweety anacron[3830]: Normal exit (0 jobs run)
Jan  8 23:01:01 sweety crond[5154]: (root) CMD (run-parts /etc/cron.hourly)
Jan  9 00:01:01 sweety crond[5355]: (root) CMD (run-parts /etc/cron.hourly)
Jan  9 00:01:03 sweety /usr/bin/crontab[5356]: (jose) LIST (jose)
Jan  9 00:01:20 sweety /usr/bin/crontab[5367]: (jose) LIST (jose)
Jan  9 00:04:53 sweety /usr/bin/crontab[5415]: (jose) REPLACE (jose)
Jan  9 00:04:53 sweety /usr/bin/crontab[5416]: (jose) LIST (jose)
Jan  9 00:05:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:05:09 sweety /usr/bin/crontab[5421]: (jose) REPLACE (jose)
Jan  9 00:05:09 sweety /usr/bin/crontab[5424]: (jose) LIST (jose)
Jan  9 00:06:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:06:01 sweety crond[5436]: (jose) CMD (ls >/dev/null 2>&1 # 
Untitled, /usr/share/pixmaps/nautilus/Bluecurve/i-executable.png)
Jan  9 00:17:24 sweety /usr/bin/crontab[5555]: (jose) REPLACE (jose)
Jan  9 00:17:24 sweety /usr/bin/crontab[5558]: (jose) LIST (jose)
Jan  9 00:17:57 sweety /usr/bin/crontab[5565]: (jose) REPLACE (jose)
Jan  9 00:17:57 sweety /usr/bin/crontab[5566]: (jose) LIST (jose)
Jan  9 00:18:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:19:45 sweety /usr/bin/crontab[5579]: (jose) REPLACE (jose)
Jan  9 00:19:45 sweety /usr/bin/crontab[5580]: (jose) LIST (jose)
Jan  9 00:20:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:20:01 sweety crond[5582]: (jose) CMD (ls  >/dev/null 2>&1 # 
Untitled, /usr/share/pixmaps/nautilus/Bluecurve/i-executable.png)
Jan  9 00:20:45 sweety crontab[5589]: (jose) BEGIN EDIT (jose)
Jan  9 00:21:14 sweety crontab[5589]: (jose) END EDIT (jose)
Jan  9 00:22:06 sweety crontab[5597]: (jose) BEGIN EDIT (jose)
Jan  9 00:22:23 sweety crontab[5597]: (jose) END EDIT (jose)
Jan  9 00:24:02 sweety crontab[5630]: (root) BEGIN EDIT (root)
Jan  9 00:24:04 sweety crontab[5630]: (root) END EDIT (root)
Jan  9 00:24:10 sweety crontab[5634]: (jose) BEGIN EDIT (jose)
Jan  9 00:24:34 sweety crontab[5634]: (jose) REPLACE (jose)
Jan  9 00:24:34 sweety crontab[5634]: (jose) END EDIT (jose)
Jan  9 00:25:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:25:59 sweety crontab[5645]: (jose) BEGIN EDIT (jose)
Jan  9 00:26:21 sweety crontab[5645]: (jose) END EDIT (jose)
Jan  9 00:26:38 sweety /usr/bin/crontab[5654]: (jose) LIST (jose)
Jan  9 00:26:54 sweety /usr/bin/crontab[5657]: (jose) LIST (jose)
Jan  9 00:27:06 sweety crontab[5663]: (jose) BEGIN EDIT (jose)
Jan  9 00:27:35 sweety crontab[5663]: (jose) REPLACE (jose)
Jan  9 00:27:35 sweety crontab[5663]: (jose) END EDIT (jose)
Jan  9 00:27:43 sweety /usr/bin/crontab[5670]: (jose) LIST (jose)
Jan  9 00:28:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:30:54 sweety /usr/bin/crontab[5709]: (jose) REPLACE (jose)
Jan  9 00:30:54 sweety /usr/bin/crontab[5710]: (jose) LIST (jose)
Jan  9 00:31:01 sweety crond[3794]: (jose) RELOAD (cron/jose)
Jan  9 00:32:01 sweety crontab[5717]: (jose) BEGIN EDIT (jose)
Jan  9 00:32:05 sweety crontab[5717]: (jose) END EDIT (jose)
Jan  9 00:36:12 sweety crontab[5738]: (jose) BEGIN EDIT (jose)
Jan  9 00:41:29 sweety crontab[5738]: (jose) REPLACE (jose)
Jan  9 00:41:29 sweety crontab[5738]: (jose) END EDIT (jose)
Jan  9 00:42:01 sweety crond[3794]: (jose) RELOAD (cron/jose)

This morning I experimented again and found out that the command does 
execute.  I changed my crontab entry to read:

00 9 9 1 1 /bin/ls -F /home/jose > /home/jose/new-home-listing.txt

and in fact, the command did execute.  Later, I tried changed the entry 
to read:

05 11 9 1 1 /bin/ls -F /home/jose > /home/jose/new-home-listing.txt

(I did this one minute before the process was supposed to execute at 
11:04 as you can see in log output below).  But the process did not 
execute.  I think it has to do with how much time in advance the task is 
scheduled.  Am I right?  Here's my log output for today:

Jan  9 08:40:07 sweety crond[3713]: (CRON) STARTUP (V5.0)
Jan  9 08:40:08 sweety anacron[3749]: Anacron 2.3 started on 2006-01-09
Jan  9 08:40:09 sweety anacron[3749]: Will run job `cron.daily' in 65 min.
Jan  9 08:40:09 sweety anacron[3749]: Jobs will be executed sequentially
Jan  9 08:52:21 sweety crontab[5474]: (jose) BEGIN EDIT (jose)
Jan  9 08:52:46 sweety crontab[5474]: (jose) END EDIT (jose)
Jan  9 08:56:38 sweety crontab[5489]: (jose) BEGIN EDIT (jose)
Jan  9 08:57:02 sweety crontab[5489]: (jose) REPLACE (jose)
Jan  9 08:57:02 sweety crontab[5489]: (jose) END EDIT (jose)
Jan  9 08:58:01 sweety crond[3713]: (jose) RELOAD (cron/jose)
Jan  9 08:59:28 sweety crontab[5528]: (jose) LIST (jose)
Jan  9 09:00:01 sweety crond[5533]: (jose) CMD (/bin/ls -F /home/jose > 
/home/jose/home-listing.txt)
Jan  9 09:01:01 sweety crond[5539]: (root) CMD (run-parts /etc/cron.hourly)
Jan  9 09:45:07 sweety anacron[3749]: Job `cron.daily' started
Jan  9 09:45:52 sweety anacron[6122]: Updated timestamp for job 
`cron.daily' to 2006-01-09
Jan  9 09:48:58 sweety anacron[3749]: Job `cron.daily' terminated
Jan  9 09:48:58 sweety anacron[3749]: Normal exit (1 jobs run)
Jan  9 10:01:01 sweety crond[6262]: (root) CMD (run-parts /etc/cron.hourly)
Jan  9 11:01:01 sweety crond[6451]: (root) CMD (run-parts /etc/cron.hourly)
Jan  9 11:03:54 sweety crontab[6461]: (jose) BEGIN EDIT (jose)
Jan  9 11:04:23 sweety crontab[6461]: (jose) REPLACE (jose)
Jan  9 11:04:23 sweety crontab[6461]: (jose) END EDIT (jose)
Jan  9 11:05:01 sweety crond[3713]: (jose) RELOAD (cron/jose)

But thanks so much Peter, your answer led me the right way.

-Jose



More information about the CentOS mailing list