LLI Wiki — My Digital Knowledge Base

List all cron jobs on Linux

Where crontabs are stored, how to list user and system cron jobs, and how to check their execution in the logs.

How to list cron jobs on Linux: user crontabs, the /etc/cron.* directories and the /etc/crontab file, and how to check their execution in the logs.

Where user crontabs are stored

User crontabs are stored in /var/spool/cron (on Debian and Ubuntu, in /var/spool/cron/crontabs). Do not edit them directly: use crontab -e.

List the jobs of a user

crontab -l                 # crontab of the current user (root here)
crontab -u testuser -l     # crontab of user testuser (root privileges required)

List the crontabs of all users referenced in /etc/passwd:

for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done

Users without a crontab only produce an informational message.

System scheduled jobs

Directory Frequency
/etc/cron.hourly/ Every hour
/etc/cron.daily/ Every day
/etc/cron.weekly/ Every week
/etc/cron.monthly/ Every month
ls -la /etc/cron.daily/
less /etc/cron.daily/logrotate

The /etc/crontab file

less /etc/crontab

Example of the beginning of the file:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

Format of a job line (see man 5 crontab):

# .---------------- 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

The user field exists only in /etc/crontab and in the files under /etc/cron.d/; a user crontab (crontab -e) does not contain it.

Check execution in the logs

grep -ic cron /var/log/* | grep -v :0
grep cron /etc/rsyslog.conf
grep -i debian-sa1 /var/log/syslog | tail -1

Also check the cron configuration in /etc/default/cron.

Mastodon LLIMastodon SocialFosstodon