scheduling tasks

Jonathan Hutchins hutchins at opus1.com
Mon Jan 20 00:15:40 CST 2003


Matt,

Placing a program in your init.d folder won't usually cause it to run at
startup.  You still need to call it from one of the startup scripts, like
rc.local, or create a link in one of the startup directories rc.<runlevel>
(this is usually done with 'chkconfig add', but can be done manually).

However, in the case of a program to update a dynamic IP address, there's a
better way.  Both dhcpcd and pump, the two client programs for getting
configuration info from a dhcp server, allow you to run a script whenever
your dhcp lease is renewed.

For dhcpcd, simply link the script to /etc/dhcpc/dhcpcd-eth0.exe

# ln -s /etc/rc.d/init.d/program-that-updates-the-IP-address
/etc/dhcpc/dhcpcd-eth0.exe

For pump, put the following line in /etc/pump.conf:

script /etc/rc.d/rc.firewall

I must admit that I don't use either of these methods, my RoadRunner IP
address hasn't changed in ages.

There are a bunch of ways to schedule a program.  As has been suggested by
others, you can put the command in crontab using crontab -e.  You will
probably want to have 'man crontab' open in another window, as the syntax of
the commands for when to run something is pretty tricky.

For something that's supposed to run hourly, daily, weekly, or monthly, you
can place a script or a link in /etc/cron.<hourly|daily|weekly|monthly>.

There's also the "at" and "batch" commands; according to 'man at':

"at and batch read commands from standard input or a specified file which
are to be executed at a later time, using the shell set by the user's
environment  variable  SHELL, the user's login shell, or ultimately
/bin/sh".

Anacron, installed with most modern distro's, checks to see if any scheduled
programs should have run while the system was down and "catches up".  This
can be a real pain in some cases, it bears considering.




More information about the Kclug mailing list