atq Command Examples in Linux

The at command is used to run a task once, at a specified time. It is not designed for repetitive or regularly scheduled tasks. The at command is very flexible. Users can specify a particular date and time, or cause the scheduled command to run after a given period of time. The command is typically used in an interactive manner, where the at command and time interval are specified, then a task is defined in an interactive prompt. This enables the user to enter a path to a script or a command to be run. Pressing Ctrl+D exits the interactive mode.

Listing scheduled tasks

Sometimes, it happens that a task has been scheduled to run at a specific time, but we forget the time at which a task is supposed to run. We can see the already scheduled tasks using one of the atq or the at command with the -l option:

$ atq
33      Mon Sep 21 14:00:00 2015 a geek
42      Sun Sep 27 16:00:00 2015 a geek

The atq command displays jobs scheduled by the current user with the job number, time, and user’s name:

$ sudo atq
34      Mon Sep 21 04:00:00 2015 a root
33      Mon Sep 21 14:00:00 2015 a geek
42      Sun Sep 27 16:00:00 2015 a geek

Running atq with sudo, lists jobs scheduled by all users.

atq Command Options

1. Show the current user’s scheduled jobs:

# atq

2. Show jobs from queue named ‘a’ (queues have single-character names):

# atq -q a

3. Show jobs of all users (run as superuser):

# sudo atq
Related Post