Friday, August 7, 2009

Using the "at" command

At is a nice command that resembles crontab, but more straightforward.
Suppose you need to run a command once, at a pre-determined time, it's ideal to use "at".
Verify atd deamon is running:
chkconfig --list | grep atd
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

Here are couple of examples:
at 1:00 am tomorrow
at -m 10:20 at -f my_cron_script 2:00 july 11

You can use "atq" to view your que:
paul@machine2 ~]$ atq
16 Wed Jul 11 02:00:00 2007 a paul
17 Sat Jul 14 02:00:00 2007 a paul
14 Sun Jul 8 22:00:00 2007 a paul
15 Tue Jul 10 02:00:00 2007 a paul

Your can use atrm, to remove undesired jobs in que:

[paul@machine2 ~]$ atrm 16 14 15

Pay attention that the undesired jobs are gone now:
[paul@machine2 ~]$ atq
17 Sat Jul 14 02:00:00 2007 a paul

The at command can always be issued by a privileged user.
Other users must be listed in the file /etc/at.allow if it exists;
otherwise, they must not be listed in /etc/at.deny.
If neither file exists, only a privileged user can issue the command.

No comments: