Linux Commands - Administrative Commands


The at command will run a script at a specified time. The command is used by typing “a”t and then the time you want the activity to occur. This will create the at> prompt enabling you to enter the commands you desire to run. When you are done press Control+D.
Here is the basic format for an at command:

at [-c | -k | -s] [-f filename] [-q queuename] [-m] -t time [date] [-l] [-r]

[-c | -k | -s]  -- refers to the shell you are using C, Korn or Bourne

-f filename

You could create a file that would be run by at.  For example a bash shell script.

-m   send mail to the user when it is complete  sent by default with /usr/sbin/sendmail

-d   this is an alias for atrm which will delete at jobs

-v  shows the time a job will be executed

-c   cats job to standard output

-t   set a time for job to run   ([[CC]YY]MMDDhhmm)

-q  queue  The a queue is reserved for at and the b queue is reserved for batch.  If you add a queue then that queue will increase in niceness, which means it will have less priority.

-V  prints version number

Who  can use at is controlled by /etc/at.allow and /etc/at.deny

If at.allow exists, only those in allow can use it.  If at.deny exists and allow does not then everyone not in deny can use it.  If neither exist only root can use it.

HH:MM format
MMDDYY, MM/DD/YY, or MM.DD.YY formats
now + time    the current time is in minutes, hours, days, or weeks. For example, now + 3 days

atq to view pending jobs

    at 5:32am
at> touch mkdir test
at> Contol+D
Unlike cron, these jobs will only run once.
-l   list jobs
-d  jobnumber delete a job
This example shows that the user root has two jobs waiting.
     at -l
 2       2005-09-11 09:07 a root
    at -d 1
This will delete job1.