at - Unix, Linux Command


Previous Page
Next Page  


at - Command Executes at a specificed time or scheduled time.



at command allows fairly complex time specifications,It accepts times of the form HH:MM to run a job at a specific time of day. (If that time is already past, the next day is assumed.) You may also specify midnight, noon, or teatime (4pm) and you can have a time-of-day suffixed with AM or PM for running in the morning or the evening. You can also say what day the job will be run, by giving a date in the form month-name day with an optional year, or giving a date of the form MMDD[CC]YY, MM/DD/[CC]YY, DD.MM.[CC]YY or [CC]YY-MM-DD. The specification of a date must follow the specification of the time of day. You can also give times like now + count time-units, where the time-units can be minutes, hours, days, or weeks and you can tell at to run the job today by suffixing the time with today and to run the job tomorrow by suffixing the time with tomorrow. For example, to run a job at 4pm three days from now, you would do at 4pm + 3 days, to run a job at 10:00am on July 31, you would do at 10am Jul 31 and to run a job at 1am tomorrow, you would do at 1am tomorrow. The definition of the time specification can be found in /usr/share/doc/at/timespec.


Tag Description
-V prints the version number to standard error and exits successfully.
-f At commands are read from standard input or the file specified and executed.
-t time run the job at time, given in the format [[CC]YY]MMDDhhmm[.ss].
-m Send mail to the user when the job has completed even if there was no output.
-M Never send mail to the user. In other words, execute the command, but do not notify the user of its output.
-v Shows the time the job will be executed before reading the job. Times displayed will be in the format "Thu Feb 20 14:50:00 1997".
-c cats the jobs listed on the command line to standard output.



 Schedule an at job using specific date and time.

 Syntax: at time date 
 $  at 12 am jan 1

warning: commands will be executed using /bin/sh
at> ls
at> ls -lrt
at> <EOT>
job 2 at Mon Jan 1 00:00:00 2018


Schedule an at job using relative time

 Syntax: at now + COUNT UNIT
 $ at now + 1 min 

warning: commands will be executed using /bin/sh
at> ls -lrt
at> ls
at> <EOT>
job 3 at Thu Jan 5 21:17:00 2017


Schedule at jobs from file using -f option

Create a text file (actions.txt in this case) that contains all the commands that you would like to be execute.

$ cat actions.txt

find /tmp -iname names.txt
rm -rf *.logs

Now to execute these commands or scripts at a specified time

$ at -f actions.txt now + 12 hour

warning: commands will be executed using /bin/sh
job 4 at Thu Jan 5 22:29:00 2017


View all the scheduled at jobs using atq or at -l

You can use atq command (or at -l), to display all the at command jobs that are scheduled or currently running.

The  atq/at -l  command will list all the pending at jobs.

The first number shown is the Job number, followed by the time in which the process is to be executed, and the user name.

$ atq


2 Mon Jan 1 00:00:00 2018 a nubo

$ at -l


2       Mon Jan  1 00:00:00 2018 a nubo


Execute at command using  nohup (nohup executes a command even after the user exits or loggedout)

 $ at -f actions.txt now + 1 min
 $ exit

at -f actions.txt now + 1 min
warning: commands will be executed using /bin/sh
job 6 at Fri Jan 6 23:47:00 2017
The jobs specified in the file actions.txt will still be running even after you exit/logged out of the server.


Additional at command time formats

You can use any one of the following at command date time formats:

$ at 10 am tomorrow

$ at 11:00 next month

$ at 22:00 today

$ at now + 1 week

$ at noon


Remove/Delete a scheduled at job using atrm or at -d 

You can use atrm command (or at -d), to delete a particular job.

To delete the job number 2, use this below command:

$ atrm 2


$ at -d  2

Previous Page
Next Page