How to run a command at a specific time once using at?
Jun 26, 2025 am 12:12 AMTo run a one-time timing task using the at command in Linux, first make sure that the at service is installed and started. 1. Check whether to install: Use which at in Debian/Ubuntu and RHEL/CentOS/Fedora; 2. If not installed, install at; 3. Make sure the atd service is running and enable power-on self-start if necessary. The basic syntax is echo "command" | at time or press Ctrl D to end after entering the command directly. Supports a variety of time formats such as now 5 minutes, 10:00 AM tomorrow, etc. Use atq to view the task list and use atrm to add task number to cancel the task. Notes include using absolute paths, processing of email notifications and permission management.
To run a command at a specific time just once, the at
command in Linux is your go-to tool. It allows you to schedule tasks without having to set up recurring jobs like with cron.
Make Sure at
Is Installed and Running
Before using at
, check if it's installed on your system. Most modern Linux distributions come with it pre-installed, but some might not. You can verify this by typing:
- On Debian/Ubuntu:
which at
- On RHEL/CentOS/Fedora:
which at
If it's not there, install it:
- Ubuntu/Debian:
sudo apt install at
- RHEL/CentOS:
sudo yum install at
orsudo dnf install at
Also, make sure the atd
service is running:
- Check status:
systemctl status atd
- Start it if needed:
sudo systemctl start atd
- Enable it to run at boot:
sudo systemctl enable atd
Basic Syntax and Usage
The general syntax is simple:
echo "your-command-here" | at your-time-here
For example, to run a script called backup.sh
at 10:30 PM today:
echo "/home/user/scripts/backup.sh" | at 22:30
You can also type the command directly after running at
:
at 22:30 > /home/user/scripts/backup.sh > <Ctrl D>
Time formats are flexible:
-
now 5 minutes
-
tomorrow
-
22:30
-
10:00 AM tomorrow
-
10:00 AM next Friday
View and Manage Scheduled Jobs
Once a job is scheduled, you can list all pending jobs with:
atq
This will show something like:
4 Wed Jul 10 22:30:00 2024 a user
If you need to cancel a job before it runs:
attrm [job number]
Each job has a number assigned when it's queued. Use atq
to find that number first.
Note: Once a job runs, it won't show up in atq
anymore — unless it failed and was moved to batch processing.
Some Common Gotchas
- Environment variables – The environment when
at
runs may be different from your current shell. Best practice is to use absolute paths for commands and files. - Email notifications – By default, output (stdout and stderr) of the command is emailed to the user. If you don't want this, redirect output:
echo "/path/to/script.sh > /dev/null 2>&1" | at now 1 minute
- Permissions – Regular users can use
at
only if they're allowed. Root can manage/etc/at.allow
and/etc/at.deny
to control access.
So yes, at
is great for one-off tasks, but keep these small details in mind to avoid surprises.
The above is the detailed content of How to run a command at a specific time once using at?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

How to quickly generate test files of a specified size? It can be achieved using command line tools or graphical software. On Windows, you can use fsutilfilecreatenew file name size to generate a file with a specified byte; macOS/Linux can use ddif=/dev/zeroof=filebs=1Mcount=100 to generate real data files, or use truncate-s100M files to quickly create sparse files. If you are not familiar with the command line, you can choose FSUtilGUI, DummyFileGenerator and other tool software. Notes include: pay attention to file system limitations (such as FAT32 file size upper limit), avoid overwriting existing files, and some programs may

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

Node Version Manager (NVM) is a simple bash script that helps manage multiple Node.js versions on your Linux system. It enables you to install various Node.js versions, view available versions for installation, and check already installed versions.NV
