Scheduling Tasks with at

Scheduling Tasks with at is one way we can defer user jobs. In Red Hat Enterprise Linux 8 we can defer jobs to run at later times using cron, systemd or at, in this blog and video we look at scheduling tasks with at.

Not all scheduled jobs in Linux need to run regularly. Regularly occurring jobs can be run using systemd timers or crond. For deferred user jobs that often need to be run at a single time we have the atd service and the at command. For any job to run via the atd service, the service must be running. We can check the status of the service with the status sub-command from systemctl but don’t forget we can also check the service is enabled and active independently:

When creating scheduled tasks with the at command we need to define when it will run, we can specify the complete date or time just some parts of it, for example, to run the command date at 13:57 tomorrow we simply use:

The time reference teatime is 4pm, how quaint! The now +1 hour style is quite useful, if the backup is going to take a while we can schedule it to happen as we leave work. We know that the backup will be ready for us the next day and we have not had to spend a lot of time thinking of formatting the date and time.

To list the contents of an at job we can use the option at-c and the job number.