• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Schedule Jobs with ‘at’ command under Linux

by admin

If you want to schedule a job to run one time only in the future (instead of scheduling it on a regular basis with cron) you can use the at command. To use at, you must first verify that the at package has been installed and that the atd service has been started.

You define an at job at the command prompt by entering at launch_time, where launch_time is the time when you want the job to begin. (For example – 12:34). Then you enter the commands you want at to run one line at a time at the at> prompt. When you finish entering commands, you save the job by pressing Ctrl+d.

The following is an example of creating a job with the at command:

# at 10:40
at> echo "Hello World" > /tmp/out
at> [EOT]
job 3 at Sun Dec 17 10:40:00 2017

To view the at jobs queue use the atq command. For example:

# atq
2       Sun Dec 17 10:37:00 2017 a root
3       Sun Dec 17 10:40:00 2017 a root

The number in the first column is the job ID of the at job. To remove a job from the at queue before the job can be executed, use the atrm command.

# atrm [job_ID]

For Example :

# atrm 2

You can also enter the commands you want to be executed by at in a text file. If you do this, then you need to enter ‘at -f file launch_time‘ at the shell prompt, where the file is the path and filename of the file.

The following table list some other commonly used at commands and options:

Command Description
atq Displays defined jobs (including job numbers, which are needed to delete a job)
atrm job_number Deletes a job (using the job number)

As with cron, you can restrict access to the atd daemon. Two files determine which users can run the at command:

  • /etc/at.allow: Users entered in this file can define jobs.
  • /etc/at.deny: Users who are not listed in this file can define jobs.

These files are text files you can modify or create. If the /etc/at.allow file exists, only this file is evaluated. If neither of these files exists, only the user root can define at jobs.

Filed Under: Linux

Some more articles you might also be interested in …

  1. kpartx: command not found
  2. updatedb: command not found
  3. “Abort command issued nexus” error messages in /var/log/messages file
  4. CentOS / RHEL 7 : Tips on Troubleshooting NTP / chrony Issues
  5. How to enable IPv6 on CentOS / RHEL 6
  6. chromium-browser: command not found
  7. dolphin Command Examples in Linux
  8. How to Set External Network For Containers in Linux Containers (LXC)
  9. How to effectively use Man Pages under Linux
  10. CentOS / RHEL : How to identify/match LUN presented from SAN with underlying OS disk

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright