LLI Wiki — My Digital Knowledge Base

Linux: list scheduled jobs (cron, at, timers) and check logrotate

Where to find cron, at, anacron and systemd timer jobs on a Linux server, and how to check logrotate.

On a Linux server, scheduled tasks can live in many places: user crontabs, system cron directories, at jobs, anacron and systemd timers. This page lists where to look and a few one-liners to enumerate them, plus how to check logrotate.

Where cron and at jobs are stored

Location Content
/var/spool/cron/* (or /var/spool/cron/crontabs) Per-user crontabs, edited with crontab -e
/etc/crontab System-wide crontab (has an extra field for the user to run as)
/etc/cron.d/* Modular crontab files, same syntax as /etc/crontab
/etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly Scripts run periodically
/var/spool/at/* (or /var/spool/cron/atjobs) Pending at jobs
/etc/anacrontab Anacron jobs
/var/spool/anacron/* Last run timestamps of anacron jobs

List the crontab of every user

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

# same thing with sudo in one shell
sudo -- sh -c 'for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done'

# pending at jobs
for user in /var/spool/cron/atjobs/*; do echo "at job for $user"; cat $user; done

See also: How can I get a list of all scheduled cron jobs on my machine?

systemd timers

systemctl list-timers

ps aux | grep 'systemd[ ]--user'
systemctl --user list-timers
find /usr/lib/systemd/ /etc/systemd -name '*.timer'
find /home '(' -path '/home/*/.local/share/systemd/user/*' \
            -o -path '/home/*/.config/systemd/*' ')' \
     -name '*.timer' 2> /dev/null

logrotate

# which cron entry runs logrotate
grep -r -s 'logrotate.conf' /etc/cron*

# last rotation status (path depends on the distribution)
cat /var/lib/logrotate.status
cat /var/lib/logrotate/logrotate.status

# test or force one configuration, verbose
logrotate -v -f /etc/logrotate.d/<name>

Background jobs

For running commands in the background and job control (bg, fg, Ctrl+Z), see:

Notes

Mastodon LLIMastodon SocialFosstodon