at command in Linux

To execute a job at a particular time only once the at command is used. The format that is given for the at command is HH:MM. The terms such as noon, midnight, next week, tomorrow, next Monday, etc. can be used with the at command.

In simple terms, the atcommand executes a job only once per day.

Syntax :

at [OPTION...] runtime
at [-V] [-q queue] [-f file] [-mMlv] timespec...
at [-V] [-q queue] [-f file] [-mMkv] [-t time]
at -c job [job...]
atq [-V] [-q queue]
at [-rd] job [job...]
atrm [-V] job [job...]
  • at: execute commands at the specified time.
  • atq: lists the pending jobs of users.
  • atrm: delete jobs by their job number.

The below example will schedule the “ls /etc” command to be executed on the next 9:00 AM once.

at 9:00 AM 
at> ls /etc
at> ^d job 3 
at 2020-02-19 09:00​

Use ^d to exit from at prompt.
Instead of the above command, you can use the below format to schedule a job using the at command.

echo "ls /etc" | at 9:00 AM

A job can be scheduled in two ways. They are,

  • To Schedule a job at a specific date and time. For example, July 21, 10 AM
  • To Schedule a job at a relative time from now. For example, 6 hours from now.

Let us learn how to schedule a job in two ways.

Examples :

To Schedule a job at a specific date and time.

Syntax :

at time date

In the below example a job is scheduled at 11 am on Jan 23

at 11 am Jan 23

Schedule a job at a relative time from now

Syntax :

at now + COUNT UNIT

In the below example, a job is scheduled at 2 minutes from now(current time).

at now + 2 min

When you give incorrect format in scheduling a job an error will prompt showing ‘Garbled time

Scheduling a background job

In the below example, You can schedule a background job to execute at 1 hour from now, (or) 1 day from now.

at now + 1 hour

at now + 1 day

In the below example you can learn the formats of the at command.

at 10 am tomorrow

at 11:00 next month

at 22:00 today

at now + 1 week

at noon

Schedule task at 6:00 AM.

at 06:00 AM

Schedule task at 06:00 AM on Monday.

at 06:00 AM Mon

Schedule task at 06:00 AM on 21’st July.

at 06:00 AM July 21​

Schedule task at 05:00 AM on coming 21’st July 2021.

at 05:00 AM 7/21/2021 
at 05:00 AM 7.21.2021

Schedule task at 05:00 AM on the same date at next month.

at 05:00 AM next month​

Schedule task at 05:00 AM tomorrow.

at 05:00 AM tomorrow​

Schedule task to execute just after 2 hours.

at now + 2 hour​

Schedule task to execute just after 45 minutes.

at now + 45 minutes​

Schedule task to execute just after 4 and 5 weeks.

at now + 4 week 
at now + 5 weeks​

Schedule tasks to execute after 3 and 4 years.

at now + 3 year 
at now + 4 years​

Schedule task to execute at midnight.

at midnight​

Scheduling task to run the commands present in a file.

To run the commands present in the file named f1 at 06.00 AM the below command is provided. In the f1 file, the command at -l is given which lists the scheduled tasks.

at -m 06:00 AM < f1

When the above command executes successfully, you'll receive a prompt similar to the example below:

//commands will be executed using /bin/sh
job 1 at Sat Feb 20 00:06:00 2021
at -l

Output :

1 Wed Dec 24 00:22:00 2003

The above example provides the same output as the atq command.

atq command in Linux

The atq command is used to list the scheduled at jobs and the running jobs..

The following atq 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.


Output :

1 2021-02-19 10:00 a Tharani

When we list jobs by root account using atq, it shows all user's jobs in the result. But if we execute it from a non-root account, it will show only that user's jobs.

You can use the program atq to view your currently-queued at jobs. Type atq to display the queue.


Output :

Fri Feb 02 10:00:00 2021 a Tharani

So to list all the scheduled at jobs give the below command. It will only work if you have super user privileges.

sudo atq and type your password, when prompted.

3 2021-01-30 11:00 a root 
5 2021-01-30 10:00 a john
1 2021-01-30 3:00 a root​

Fields description :

  • First filed: job id
  • Second filed: Job execution date
  • third filed: Job execution time
  • Last field: User name, under which job is scheduled.
atrm command in Linux

The atrm command is used to delete the scheduled at jobs using the job number.

For example, the below command will delete the job which has the job number 10

atrm 10
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions