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

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

Firefox browser is the default browser for most modern Linux distributions such as Ubuntu, Mint, and Fedora. Initially, its performance might be impressive, however, with the passage of time, you might notice that your browser is not as fast and resp

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and
