The at command in Linux: programming specific tasks

Introduction

In Linux system management, you often need to run a command or script at a specific time in the future without keeping an open session. Whilecronmanages recurring tasks, commandatis designed for one-time work. This article explains whatat, how it is installed, its syntax and practical examples to program tasks quickly and safely.

What is the at command

The commandatbelongs to the packageatand allows to specify an execution time for any command or command sequence. In invoking it,atopens an interactive prompt where the order is written; at the end ofCtrl+D, work is kept in the tail ofatAnd it runs at the right time. The devilatdWatch the tail and launch the processes when your time comes.

Installation and verification

In most distributionsatIt's already installed. If missing, it is installed with the package manager:

  • In Debian / Ubuntu:sudo apt-get update && sudo apt-get install at
  • In Fedora:sudo dnf install at
  • In Arch Linux:sudo pacman -S at

After installation, activate the demon:

sudo systemctl enable --now atd

Check your status withsystemctl status atd.

Basic syntax

The simplest way to useatis:

at HH:MM

After pressing Enter, the prompt opensat>where you write the command or commands you want to run. At the end, it is pressedCtrl+D(or is writtenEOF) to close the entry and schedule the task.

You can also pass the entry directly from a pipe or file:

echo 'comando a ejecutar' | at HH:MM

Or:

at HH:MM < archivo.txt

Practical example

To show a reminder at 15: 00:

at 15: 00 > echo 'Meeting in 5 minutes' > Ctrl + D

The message will appear in the terminal at the time indicated.

Advanced date and time

The command accepts formats likenow + 30 minutes, at 22:00 tomorroworat 10:00 2025-12-31. It also allows to use expressions liketeatime(equivalent to 16: 00).

Work management

List the outstanding work withatq. Remove a job with your number usingatrm número. Several numbers are separated by spaces.

Advantages on cron

  • It does not require editing the system or user chrontab.
  • Allows you to specify an exact time easily, even using natural language asnow + 45 minutes.
  • The process is automatically removed from the tail after its execution, avoiding accumulation of obsolete inputs.
  • It is useful in scripts that need to schedule a future action based on a condition detected in running time.

Security constraints and considerations

  • Depending on the system configuration, some users may be restricted to useatby the files/etc/at.allowand/etc/at.deny. If these files exist, only users listed inat.allowcan schedule tasks, while those included inat.denyare prohibited.
  • The tasks are run with the user environment that programmed them, so environment variables likePATHmay differ from those of an interactive session; it is good practice to use absolute routes in the commands.
  • If the devilatdIt's not running, the tasks will never be launched. Check your state after reboot.
  • In very restricted environments (containers, embedded systems) it mayatis not available or its use is deactivated by security policies.

Good practices

  • Always use absolute pathways for binaries and scripts (e.g.,/usr/bin/rsyncinstead ofrsync).
  • Test your command or script before scheduling it withatrunning it directly at the terminal.
  • Record the output of the programmed tasks by redirecting it to a log file:echo '/ruta/script.sh' | at 02:00 > /var/log/mi_tarea.log 2>&1(although the redirection is done within the command you pass toat).
  • Check the tail regularly withatqto make sure there are no forgotten jobs left.
  • It documents in a wiki or operations notebook the specific tasks that programs, especially if they affect production.

Conclusion

The commandatis a light and powerful tool to program unique executions in Linux systems. Its simple syntax, the ability to accept input from stdin or files and its integration with the demonatdmake it ideal for situations wherecronIt would be excessive. By understanding their operation, date / time options and best use practices, managers can automate specific tasks reliably and safely, improving day-to-day efficiency in server and workstation management.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish