Skip to main content
Hello, and welcome to this lesson on verifying the completion of scheduled jobs on CentOS Stream 8 (and similar Linux systems). By default, cron, anacron, and at write activity to the system logging facility. That makes it straightforward to confirm whether scheduled jobs ran and, when needed, to capture their output.
A dark presentation slide showing the heading "Demo" and the text "Verify Completion of Scheduled Jobs" on the left. The right side has a large video placeholder with a small film camera icon and a KodeKloud logo in the top-right.

Why this matters

System administrators frequently need to verify that scheduled tasks completed successfully or produced the expected output. Knowing where and how cron/anacron/at log their activity helps you troubleshoot failures, capture output, and set up notifications.

Cron — per-user crontab

To demonstrate, add two simple per-user cron jobs that run every minute. Edit the crontab with crontab -e and add these lines:
[aaron@LFCS-CentOS ~]$ crontab -e
# Example crontab entries (run every minute)
* * * * * /bin/echo "Just testing cron"
* * * * * /bin/echo "Just testing cron again"
Cron records job execution events in /var/log/cron. The log lines include the literal “CMD” for executed commands, making it easy to filter for executions:
[aaron@LFCS-CentOS ~]$ sudo grep 'CMD' /var/log/cron
Mar 24 01:05:01 LFCS-CentOS CROND[9203]: (aaron) CMD (/bin/echo "Just testing cron")
Mar 24 01:05:01 LFCS-CentOS CROND[9204]: (aaron) CMD (/bin/echo "Just testing cron again")
Mar 24 01:06:01 LFCS-CentOS CROND[9264]: (aaron) CMD (/bin/echo "Just testing cron")
Mar 24 01:06:01 LFCS-CentOS CROND[9265]: (aaron) CMD (/bin/echo "Just testing cron again")
Mar 24 01:07:02 LFCS-CentOS CROND[9347]: (aaron) CMD (/bin/echo "Just testing cron again")
Mar 24 01:07:02 LFCS-CentOS CROND[9348]: (aaron) CMD (/bin/echo "Just testing cron")
...
Note: Some systems include the command output in the logs under keys like “CMDOUT” or similar. If you expect output from a cron job, search /var/log/cron for CMDOUT or query the journal with journalctl. When finished testing, remove the user crontab entry:
[aaron@LFCS-CentOS ~]$ crontab -r

System-wide crontab (/etc/crontab)

The system-wide crontab at /etc/crontab sets environment variables and shows the expected syntax (including the user field). It also contains MAILTO, which cron/anacron uses to email job output if system mail is configured:
[aaron@LFCS-CentOS ~]$ cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# * * * * *  user-name  command to be executed

Anacron — for machines not running 24/7

Anacron is designed for systems that may be powered off periodically. Jobs use a named identifier, which simplifies searching logs. Example /etc/anacrontab:
# /etc/anacrontab: configuration file for anacron
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
RANDOM_DELAY=45
START_HOURS_RANGE=3-22

# period in days  delay in minutes  job-identifier  command
1       5        cron.daily       nice run-parts /etc/cron.daily
7       25       cron.weekly      nice run-parts /etc/cron.weekly
@monthly 45      cron.monthly     nice run-parts /etc/cron.monthly
1       10       test_job         /bin/echo "Testing anacron"
To run anacron jobs immediately (suppress random delay), use:
[aaron@LFCS-CentOS ~]$ sudo anacron -n
Force execution regardless of last-run timestamps with -f:
[aaron@LFCS-CentOS ~]$ sudo anacron -n -f
Anacron logs show start/stop events in /var/log/cron, but they typically only note that output was produced rather than including the full stdout. Example:
[aaron@LFCS-CentOS ~]$ sudo grep anacron /var/log/cron
Mar 24 01:01:01 LFCS-CentOS anacron[8903]: Anacron started on 2022-03-24
Mar 24 01:01:01 LFCS-CentOS anacron[8903]: Will run job `test_job' in 12 min.
Mar 24 01:13:01 LFCS-CentOS anacron[8903]: Job `test_job' started
Mar 24 01:13:01 LFCS-CentOS anacron[8903]: Job `test_job' terminated (produced output)
Mar 24 01:13:01 LFCS-CentOS anacron[8903]: Normal exit (1 job run)
Capture anacron job output in the systemd journal by piping to systemd-cat. Edit the job entry:
1 10 test_job /bin/echo "Testing anacron" | systemd-cat --identifier=test_job
Force anacron to run and then inspect the journal:
[aaron@LFCS-CentOS ~]$ sudo anacron -n -f
[aaron@LFCS-CentOS ~]$ journalctl -e | grep test_job -C3
Mar 24 01:19:38 LFCS-CentOS anacron[9869]: Job `test_job' started
Mar 24 01:19:38 LFCS-CentOS test_job[9887]: Testing anacron
Mar 24 01:19:38 LFCS-CentOS anacron[9869]: Job `test_job' terminated
Remember to remove any temporary test entries from /etc/anacrontab after testing.

at (one-off scheduled jobs)

at schedules one-time jobs. To schedule a job to run in one minute and capture its output to the journal:
  1. Create the at job; after entering your commands finish with Ctrl-D:
[aaron@LFCS-CentOS ~]$ at 'now + 1 minute'
warning: commands will be executed using /bin/sh
at> echo "My at job produced this output" | systemd-cat --identifier=at_scheduled_backup
at> <Ctrl-D>
job 4 at Thu Mar 24 01:22:00 2022
The at daemon logs job starts to /var/log/cron:
[aaron@LFCS-CentOS ~]$ sudo grep atd /var/log/cron
Mar 24 01:04:00 LFCS-CentOS atd[9079]: Starting job 2 (a0000201a3224c) for user 'aaron' (1000)
Mar 24 01:07:00 LFCS-CentOS atd[9319]: Starting job 3 (a0000301a3224f) for user 'aaron' (1000)
Because we piped the job to systemd-cat, its output appears in the journal:
[aaron@LFCS-CentOS ~]$ journalctl | grep at_scheduled_backup
Mar 24 01:07:00 LFCS-CentOS at_scheduled_backup[9326]: My at job produced this output
Mar 24 01:23:14 LFCS-CentOS at_scheduled_backup[10028]: My at job produced this output

Quick comparison: cron, anacron, and at

SchedulerTypical use caseWhere to checkCaptures stdout by default?
cron (per-user & system)Regular, recurring jobs on always-on systems/var/log/cron (or journalctl)Sometimes (depends on config); logs CMD lines
anacronJobs on systems that are periodically powered off/var/log/cron and journalctlLogs events; pipe to systemd-cat to capture stdout
atOne-off, ad-hoc jobs/var/log/cron and journalctlPipe to systemd-cat to capture stdout

Practical tips

  • Use journalctl to search by custom identifiers when you pipe output through systemd-cat.
  • If your distribution doesn’t use /var/log/cron, check /var/log/messages or /var/log/syslog, or query the journal directly.
  • Configure MAILTO in /etc/crontab or per-user crontab if you have local mail delivery enabled and prefer email notifications for output.
On some distributions, scheduled-job messages are recorded in /var/log/messages or /var/log/syslog instead of /var/log/cron. If you don’t find entries in /var/log/cron, search those files or use journalctl to query the systemd journal.

Summary

  • Check /var/log/cron for CROND/CMD messages to verify cron job execution.
  • Anacron reports job starts/stops; to capture output, pipe the job to systemd-cat and then inspect journalctl.
  • at logs job starts in the system logs; use systemd-cat to capture output into the journal when needed.
  • Use MAILTO for email delivery of job outputs if you have the mail system configured.
Links and references

Watch Video

Practice Lab