Thursday, August 9, 2007

at - jobs scheduling howto

Here's another way to queue and execute jobs for later execution. This approach is handy when you need to execute a one time job scheduled in the future, that is ahead of the host current date and time.

This blog entry covers job scheduling using at.

ATD DAEMON SERVICE:
===============

Before anyone can make use at command, atd daemon service should be up and running. Like so:

# service atd start
# service atd status

Remember, if you need them to start permanently during after reboot, make sure you configure them like so:

# chkconfig --levels 35 atd on

# at -f myscript.sh -v 11:45

After this successful schedule, at return at job ticket ID 7 like so
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
job 7 at Fri Aug 10 10:54:00 2007
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How to list out all 'at' scheduled jobs

# atq
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 Fri Aug 10 10:54:00 2007 a root
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

All 'at' jobs are listed as files from /var/spool/at .

How to delete 'at' job ticket ID?

# atrm 7

AT RESTRICTIONS
===============

/etc/at.allow - usernames listed here are permitted to use at mechanism
/etc/at.deny - usernames listed here are denied to use at mechanism;
if at.allow does not exist and at.deny exist with no usernames, all user accounts
are permitted to use at mechanism
If both of them does not exists, only root can use the 'at' mechanism.

How to get more detailed info of 'at' scheduled job?

# atrm -c 7

'AT' mechanism can also send email to the user when that particular job has completed.

More samples.

Executes myscript.sh around 11:45AM
# at -f myscript.sh 11:45AM

# at -f myscript.sh 11:45AM tommorrow
# at -f myscript.sh 11:45AM + 2 days
# at -f myscript.sh 11:45AM Aug 10
# at -f myscript.sh 11:45AM monday
# at -f myscript.sh 11:45AM next week

You can further study time specification from this file /usr/share/doc/at-3.1.10/timespec .

HTH

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy