[Gllug] Advanced versions of cron for scheduling

James McGuigan james-lists at worldfuturecouncil.org
Sat Jul 16 09:29:22 UTC 2005


Richard Jones wrote:

> (2) Run a job continually - after it finishes, schedule it to run
> again.
> 
> A shell script, while true; do ... done, solves this, but there are
> maintainability concerns (eg for one, how to start the script when the
> machine boots, from a non-root user account, without requiring root
> access?).

If you want to keep all the config in the crontab file, then maybe a put 
a comment at the end of the line with the word "bootup" (or any other 
unique keyword) and have a small boot time script that reads the 
relevant parts from the crontab.

#!/bin/bash
cat /etc/crontab | grep bootup | \
awk '/.*/ {print $7 $8 $9 $10 $11 $12}' > cronboot.sh;
bash cronboot.sh


As for running as a non-root user, is getting root to sudo to another 
user a valid option.
sudo -u nonrootuser beep
su nonrootuser -c  'beep'

> (4) Running jobs regularly, but at odd intervals.
> 
> For example, one request I've had was to run a job every 45 minutes.
> This isn't easy to express in a crontab.

Not sure if this will work, but 60*24 / 45 minutes is 1/32 of a day:

# min hour day   month dow user command
   *   *    */32  *     *   root /usr/local/bin/do-something.pl # bootup

-- 
Rules are written for those who lack the ability to truly reason,
But for those who can, rules become nothing more than guidelines,
And live their lives governed not by rules but by reason.
      - James McGuigan

Earth Emergency - A Call to Action (www.earthemergency.org)
Sustainable Society Directory (www.sustainable-society.co.uk)
World Future Council Initiative (www.worldfuturecouncil.org)
Open co-op (http://open.coop)
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list