Web Hosting Talk







View Full Version : Crontab - WTF! Once and for All!


Maximux
09-09-2002, 07:43 PM
This should be very simple. I ask that someone help me to clear my confusion.

What I want to do;

# Run program_name once a minute
* * * * * root /usr/sbin/cobalt/program_name 2>&1

# Run program_name every five minutes
5,10,15,20,25,30,35,40,45,50,55 * * * * root /usr/sbin/cobalt/program_name 2>&1

# Run program_name each minute
* * * * * root /usr/sbin/cobalt/program_name 2>&1


I have added these entries into /var/spool/cron/root (emacs) as they appear above with the exception that I have changed the program_name.

I run
root# crontab -l
and I get ;
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.2302 installed on Mon Sep 9 15:28:43 2002)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)


35 07,10,13,16,19,22,01 * * * /usr/local/program_name/program_name >/dev/null 2>&1

# Run program_name once a minute
* * * * * root /usr/sbin/cobalt/program_name 2>&1

# Run program_name every five minutes
5,10,15,20,25,30,35,40,45,50,55 * * * * root /usr/sbin/cobalt/program_name 2>&1

# Run program_name each minute
* * * * * root /usr/sbin/cobalt/program_name 2>&1

Now, from my understanding there is no need to have a cron.update file in /var/spool/cron/ because according to man crontab that is no longer necessary.

My programs never run!

Should I edit /etc/crontab instead? I'm more confused now than anything. This just does not seem that it should be this difficult - it is cron.

notice that these cronjobs are in minutes...not
cron.daily
cron.half-hourly
cron.hourly
cron.monthly
cron.quarter-daily
cron.quarter-hourly
cron.weekly

What am I missing? Anyone, please, I am pulling my hair out.

Thank you,

Maximux

Maximux
09-09-2002, 09:02 PM
ok, I have reverted /var/spool/cron/root back to it's original state.

Then I did;
mkdir /path/to/cronjob_script
emacs /path/to/cronjob_script

35 07,10,13,16,19,22,01 * * * /usr/local/program_name/program_thing >/dev/null 2>&1

# Run program_name once a minute
* * * * * /usr/sbin/cobalt/program_name 2>&1

# Run program_name every five minutes
5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/sbin/cobalt/program_name 2>&1

# Run program_name each minute
* * * * * /usr/sbin/cobalt/program_name 2>&1

saved & closed.

Then ran;
crontab /path/to/cronjob_script

Then did a;
crontab -l (as root)

[root cron]# crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/path/to/cronjob_script installed on Mon Sep 9 18:06:45 2002)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)

35 07,10,13,16,19,22,01 * * * /usr/local/program_name/program_thing >/dev/null 2>&1

# Run program_name once a minute
* * * * * /usr/sbin/cobalt/program_name 2>&1

# Run program_name every five minutes
5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/sbin/cobalt/program_name 2>&1

# Run program_name each minute
* * * * * /usr/sbin/cobalt/program_name 2>&1


Notice this time I left out the "root" parameter of the cron line.

Still - my programs are not running!?!

Anyone, anyone, Bueller, Anyone?

Maximux
09-09-2002, 09:28 PM
for kicks I just issued
/etc/rc.d/init.d/crond restart as root.

Nadda.

Pulease!

Maximux
09-10-2002, 12:02 AM
ok, it appears that the second attempt I did worked. Each of the scripts executed as expected and the process completed without errors.

I recommend anyone / everyone to use my second approach to execute minute based cronjobs. I come from a slackware background and have never had trouble with crond configs until now.

I have to admit that part of the problem was a credit card validation process that was hung ( ON WINDOWS, NO DOUBT) and once I had the windows ...um, admins click reset my **** starting working.

If anyone cares or wants to peak at what all this fuss is about check out http://hosting.firstinter.net for a preview of First Internet Corps. new hosting pages revolving around a linux farm.

Hope someone learns something from all this...

Maximux

cbtrussell
09-10-2002, 10:47 AM
Maximux,

Sorry, just saw your post. Glad you figured it out, but more importantly thanks for posting your results for folks who have the same issue in the future.

Brandon

Maximux
09-10-2002, 11:14 AM
Thanks anyways - I would still like to hear from anyone who has more experience with this layout of cron than I, feel free to expand or futher explain anything I may have been missed.

In particular, did restarting crond do anything? Was the first scenario using /var/spool/cron/root correct and I just missed the crontrab execution?...

Im happy, it works this morning and I get to be the hero of the day!

Maximux