Schedule a one-time backup run for the next maintenance window
using
at
and prove it is queued with the expected command. Inspect the
generated job script with
at -c
and cancel it cleanly with
atrm
.
A user requests that a heavy backup job run exactly once at 2:30 AM tomorrow so it does not impact daytime performance. You need to confirm the scheduler is available, queue the job correctly, and validate that the queued content matches the intended command.
Use
at
for one-off maintenance work that should not become a
recurring cron entry. Always verify the queue and job body
so you can prove what will run before the window opens.
atd service is running./home/dev/backup.sh
for 2:30 AM tomorrow.
atq
.
at -c
.
atrm
.
at
queue for one-time execution versus cron for recurring jobs.
atd
) to execute queued work.
atq
).
at -c
(expanded environment + command payload).
atrm
to avoid stale scheduled work.
systemctl status atd
at
depends on
atd
to execute queued jobs. If the daemon is inactive, the job
may be accepted but will not run on schedule.
● atd.service - Deferred execution scheduler
Loaded: loaded (/lib/systemd/system/atd.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2025-07-22 09:41:37 UTC; 1h 23min ago
Docs: man:atd(8)
Main PID: 672 (atd)
Jul 22 09:41:37 lpic-lab42 systemd[1]: Started Deferred execution scheduler.
echo '/home/dev/backup.sh' | at 2:30 AM tomorrow
Piping commands into
at
queues them for one-time execution at the specified time.
The scheduler returns a job number that becomes your handle
for inspection and cancellation.
job 8 at Thu Jul 25 02:30:00 2025
atq
atq
lists queued jobs, including job ID, scheduled time, and job
owner. This is your primary verification that the job is
pending.
8 Thu Jul 25 02:30:00 2025 a vonds
at -c 8
at -c
prints the exact script that will run, including environment
setup and the command payload. Use this to validate that the
queued work matches the approved change.
#!/bin/sh
# atrun uid=1000 gid=1000
# mail vonds 0
umask 22
cd /home/vonds || {
echo 'Execution directory inaccessible'; exit 1;
}
/home/dev/backup.sh
atrm 8
Use
atrm
to remove a queued job by job number. This prevents stale
scheduled work from running after a maintenance window
changes.
# Verify removal:
atq
If
systemctl status atd
shows the service is not running, queued jobs will not
execute. Start and enable the service, then re-queue the job
and verify it appears in
atq
.
Always inspect with
at -c <jobid>
before the window opens. If the command payload is wrong,
remove the job with
atrm
and queue it again rather than trying to “patch” it.
Human-friendly specs can be misread. Confirm the resolved
schedule in the
at
output and in
atq
before you leave the change window.
If job submission fails, check
/etc/at.allow
and
/etc/at.deny
policy and validate the user is permitted to schedule jobs.
Confirm daemon logs if the failure is not explicit.
This lab should leave no persistent configuration changes. Your cleanup is ensuring the queue is clear and no unintended jobs remain scheduled.
atq
systemctl status atd
atq
returns no pending jobs, and
atd
is active so future approved one-time work can run.
systemctl status atd
: Shows whether the atd service is active.
status
: Displays current state and recent journal output.
echo '<cmd>' | at <time>
: Queues a one-time job by passing commands to
at
via standard input.
|
: Pipes output from the left command into the right
command.
atq
: Lists queued at jobs.
at -c <jobid>
: Prints the exact script that will execute for a queued job.
-c
: Displays job contents (environment + commands).
atrm <jobid>
: Removes a queued job by job ID.