atq

process managementlinux
The atq command is one of the most frequently used commands in Linux/Unix-like operating systems. atq The atq command lists the pending jobs for the at command scheduler. It displays the job number, date, hour, queue, and username for each scheduled task.

Quick Reference

Command Name:

atq

Category:

process management

Platform:

linux

Basic Usage:

atq [options] [arguments]

Common Use Cases

    Syntax

    atq [-V] [-q queue] [-v]

    Options

    Option Description
    -V Display version information
    -q queue Show only jobs in the specified queue
    -v Show the time the job will be executed in a more verbose format
    -u user Show only jobs of the specified user (only available for privileged users)

    Examples

    How to Use These Examples

    The examples below show common ways to use the atq command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    #

    Basic Examples:

    # List all pending at jobs
    atq
    # List jobs in a specific queue atq -q a
    # List jobs with detailed information (verbose) atq -v

    Advanced Examples:

    # Filter jobs by username (requires root privileges)
    sudo atq -u username
    # Combine with grep to filter by date atq | grep "2023-07"
    # Output job queue as part of a script atq > /tmp/scheduled_jobs.txt
    # Use with watch to monitor job queue in real-time watch atq # Check if there are any jobs in the queue if [ $(atq | wc -l) -gt 0 ]; then echo "Jobs are scheduled"; fi

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    Understanding the Output:

    The atq command displays each job on a separate line with the following information:

    • Job number - A unique identifier used to refer to the job (e.g., with atrm)
    • Date - When the job is scheduled to run
    • Hour - The time the job will execute
    • Queue - The queue the job is in (a single letter from a to z)
    • Username - The user who created the job

    Usage Tips:

    • atq is equivalent to the command at -l
    • The job number shown by atq is needed for viewing job details (at -c job_number) or removing jobs (atrm job_number)
    • If no jobs are scheduled, atq will produce no output
    • The atd daemon must be running for at jobs to execute and for atq to function properly
    • Only root can see other users' jobs, regular users can only view their own jobs
    • Queues are used to set priorities, with 'a' being the highest priority and 'z' the lowest
    • The batch command schedules jobs in queue 'b' by default
    • Consider using at -c job_number to inspect the exact commands that will be executed for a specific job

    Troubleshooting:

    • If atq returns nothing, it may indicate that no jobs are scheduled or that the atd daemon is not running
    • Check if the atd service is active using systemctl status atd
    • Verify permissions in /etc/at.allow and /etc/at.deny if you are unable to see expected jobs
    • If access is denied, you may not have permission to use the at facility
    • Use journalctl -u atd to check for any error messages related to the atd daemon

    Related Commands

    These commands are frequently used alongside atq or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the atq command works in different scenarios.

    $ atq
    View All Commands