> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scheduling Future Tasks

> Guide to reliably scheduling one time and recurring maintenance tasks using at, cron, and systemd timers, including managing environment settings and temporary file cleanup.

Or imagine logs slowly filling up the disk until services suddenly stop working.

Without a reliable scheduling mechanism, critical maintenance tasks depend on memory and manual execution — and that creates outages. This guide shows how to schedule jobs so important tasks run automatically and on time, even when no one is watching.

This article begins with scheduling one-time jobs using tools like `at`. It then covers recurring jobs with `cron`, explores `systemd` timers as a modern integration option, and finishes with managing temporary files on Red Hat Enterprise Linux 10.

By the end, you'll know how to make maintenance and cleanup tasks run reliably, on schedule, and with predictable environment settings.

![A dark-themed presentation slide titled "Overview" with bullet points about task scheduling, including using the at command, cron for recurring jobs, and systemd timers. The slide also mentions managing temporary files and automating cleanup tasks.](https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Scheduling-Future-Tasks/Scheduling-Future-Tasks/overview-scheduling-at-cron-systemd-cleanup.jpg?fit=max\&auto=format\&n=9E2T0ocsNwD7Od8i\&q=85\&s=b5b69b0a6d99c0f2ad187ddc7179c936)

## When you need one-time scheduled execution

Sometimes you need to run one or more commands at a specific point in time. Examples:

* A user schedules a long-running maintenance task to run overnight.
* An administrator queues a safety job to reset firewall settings in ten minutes.
* You want a one-off backup or data migration to run at a future date.

For one-time scheduled execution, `at` is a simple and widely available utility. It accepts commands or scripts and runs them once at a specified future time.

* `at` queues the job: the provided commands are saved into a spool directory.
* `atd` (the at daemon) monitors that spool directory. When the scheduled time arrives, `atd` executes the job and then removes it from the queue.
* Important: `at` creates the job entry; `atd` performs the execution.

![A dark-themed presentation slide titled "Scheduling One-Time Jobs" with a calendar icon in the center. The caption reads: "A scheduling utility that runs a command once at a specified future time."](https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Scheduling-Future-Tasks/Scheduling-Future-Tasks/one-time-job-scheduler.jpg?fit=max\&auto=format\&n=9E2T0ocsNwD7Od8i\&q=85\&s=4d066d38715ceb254cd3bf137cd454e1)

### How at jobs run and common pitfalls

* at jobs execute in a non-interactive shell (usually `/bin/sh`), not your interactive `bash` session.
* Profiles and interactive shell configuration files (for example `.bashrc` or `.profile`) are not sourced.
* Environment variables, aliases, and PATH modifications from your interactive session are not available to `at` jobs unless you explicitly provide them.

![A dark-themed infographic titled "How It Works" with five numbered gear icons illustrating a job scheduling workflow. It shows steps: schedule a job, save the command in a spool directory, the atd daemon monitors it, atd executes the job at the scheduled time, and the job is then removed.](https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Scheduling-Future-Tasks/Scheduling-Future-Tasks/atd-job-scheduling-workflow-infographic.jpg?fit=max\&auto=format\&n=9E2T0ocsNwD7Od8i\&q=85\&s=2e6e4e9c04b1813dab1e892f7568c862)

When creating `at` jobs, always use absolute paths for executables and file locations (for example, `/usr/bin/rsync` or `/home/student/myjob`). If your job depends on environment variables, set them explicitly in the job's text.

![A dark-themed "Important Information" panel with three cards, each showing a blue outline icon. The cards give shell-related tips: "'at' jobs run in a non-interactive shell," interactive settings like ".bashrc" or aliases may not load, and use absolute paths to avoid command failures.](https://mintcdn.com/kodekloud-c4ac6d9a/9E2T0ocsNwD7Od8i/images/Prep-Course-Red-Hat-Certified-System-Administrator-RHCSA/Scheduling-Future-Tasks/Scheduling-Future-Tasks/at-noninteractive-shell-use-absolute-paths.jpg?fit=max\&auto=format\&n=9E2T0ocsNwD7Od8i\&q=85\&s=7413a8a86e7606601803977f98748293)

## Practical demo — scheduling one-time jobs with at

Follow these steps to schedule and manage one-time `at` jobs:

1. Verify the `atd` service is running:
   * `systemctl status atd`
2. Queue a job using `at` with a time specification:
   * Examples: `16:30`, `10:00 tomorrow`, `14:00 2026-05-01`, `8:00 May 2`
3. List pending jobs: `atq`
4. View a job's contents: `at -c <jobid>`
5. Remove a queued job: `atrm <jobid>`

Summary of common commands:

| Action | Command |
| - | - |
| Start/Check `atd` service | `systemctl status atd` |
| Queue a job | `at 16:30` (then type commands and end with Ctrl-D) |
| List pending jobs | `atq` |
| Show job contents | `at -c <jobid>` |
| Remove a job | `atrm <jobid>` |

Example interactive session (the `at` prompt requires entering the job content and finishing with Ctrl-D):

```bash theme={null}
student@control:~$ systemctl status atd
● atd.service - Deferred execution scheduler
     Loaded: loaded (/usr/lib/systemd/system/atd.service; enabled; preset: enabled)
     Active: active (running) since Wed 2026-04-22 11:37:37 EEST; 1h 44min ago
   Docs: man:atd(8)
   Main PID: 1293 (atd)
      Tasks: 1 (limit: 23012)
     Memory: 320K (peak: 1.2M)
        CPU: 7ms
     CGroup: /system.slice/atd.service
             └─1293 /usr/sbin/atd -f

Apr 22 11:37:37 control systemd[1]: Started atd.service - Deferred execution scheduler.
Apr 22 11:37:37 control (atd)[1293]: atd.service: Referenced but unset environment variable evaluates to an empty str
student@control:~$ at 16:30
warning: commands will be executed using /bin/sh
at Wed Apr 22 16:30:00 2026
at> echo test > /home/student/myjob
at> <EOT>
job 1 at Wed Apr 22 16:30:00 2026

student@control:~$ at 10:00 tomorrow
warning: commands will be executed using /bin/sh
at Thu Apr 23 10:00:00 2026
at> echo test > /home/student/myjob2
at> <EOT>
job 2 at Thu Apr 23 10:00:00 2026

student@control:~$ at 14:00 2026-05-01
warning: commands will be executed using /bin/sh
at Fri May  1 14:00:00 2026
at> echo test > /home/student/myjob3
at> <EOT>
job 3 at Fri May  1 14:00:00 2026

student@control:~$ at 8:00 May 2
warning: commands will be executed using /bin/sh
at Sat May  2 08:00:00 2026
at> echo test > /home/student/myjob4
at> <EOT>
job 4 at Sat May  2 08:00:00 2026

student@control:~$ atq
1    Wed Apr 22 16:30:00 2026 a student
2    Thu Apr 23 10:00:00 2026 a student
3    Fri May  1 14:00:00 2026 a student
4    Sat May  2 08:00:00 2026 a student
student@control:~$
```

Inspect a queued job:

```bash theme={null}
student@control:~$ at -c 1
#! /bin/sh
# atrun uid=1000 gid=1000
exec /bin/sh -c 'echo test > /home/student/myjob'
```

Remove a job from the queue:

```bash theme={null}
student@control:~$ atrm 1
student@control:~$ atq
2    Thu Apr 23 10:00:00 2026 a student
3    Fri May  1 14:00:00 2026 a student
4    Sat May  2 08:00:00 2026 a student
student@control:~$
```

This demonstrates how `at` lets you schedule precise, one-time command execution. To ensure reliable runs:

* Use absolute paths for binaries and target files.
* Export or set any required environment variables inside the job text.
* Test the commands in a non-interactive shell if possible (for example, `sh -c '...command...'`) to verify behavior matches what `atd` will run.

Because `at` jobs run in a non-interactive shell, commands that rely on environment settings, interactive prompts, or unlocked credentials may fail. Always test jobs and provide explicit environment configuration.

## Links and references

* [Linux man page: at(1)](https://man7.org/linux/man-pages/man1/at.1.html)
* [Linux man page: atd(8)](https://man7.org/linux/man-pages/man8/atd.8.html)
* [systemd.timer — systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.timer.html)
* [Red Hat Enterprise Linux documentation](https://access.redhat.com/documentation/en-us/)

Next: recurring jobs with `cron`, and using `systemd` timers for tighter integration with services.

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/red-hat-certified-system-administrator-rhcsa/module/47c5bb98-697d-4682-97b5-abdeb8a3f704/lesson/606073f6-ac8a-4f65-8eba-be558575a4f1)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.