Off-python-topic: Cron jobs on linux...help

John W. Baxter jwbnews at scandaroon.com
Thu Mar 15 18:43:24 EST 2001


In article <mailman.984684081.4438.python-list at python.org>,
 "Chris Richard Adams" <chrisa at ASPATECH.COM.BR> wrote:

> I'd like to ask two things about the cron tool that comes with Linux -
> have RedHat 6.2.
>  
> 1.) I have a script that runs fine when I am logged in a the user who
> owns it.  I have env variables that are needed and these are loaded in
> the .bash profile as that user logs in.  As that user, I set a cron job
> putting the pathname of the script.  It runs, but fails because it
> appears the  environment vars are not set.  I can work around it by
> putting all the vars in the script of course, but what might be the
> problem?

Cron deliberately sets up a VERY limited set of environment variables 
when it starts a process.  [For example, the PATH is likely not to 
contain what one needs, so full path names are generally given.]

See
   man env

>  
> 2.) I want the script to run each 20 minutes.  With only the 5 time
> parameters to set, I can't do this?

This snippet from /etc/crontab runs the elided stuff every 5 minutes 
much of the day and every 15 minutes overnight.

0-55/5 7-23 * * * root nice /...
5-50/15 0-6 * * * root nice /...

You don't have to abbreviate that much...the minute can be shown as
0,5,10,15, and so on.

See
   man -S 5 crontab

(-s rather than -S on many Unix systems)

  --John

-- 
John W. Baxter   Port Ludlow, WA USA  jwbnews at scandaroon.com



More information about the Python-list mailing list