How to List Cron Jobs in Linux

Published on

3 min read

Scheduling Cron Jobs with Crontab

Cron is a scheduling daemon that allows you to schedule the execution of tasks at specified intervals. These tasks are called cron jobs and can be scheduled to run by a minute, hour, day of the month, month, day of the week, or any combination of these.

Cron jobs are typically used to perform system maintenance operations. For example, a cron job can be set up to automate repetitive tasks such as backing up databases , updating the system with the latest security patches, clearing cache, sending emails, and so on.

This article explains how to list the cron jobs.

Listing Users Cron Jobs

Users’ crontab files are named based on the user’s name, and their location varies by operating systems. In Red Hat based distributions such as CentOS, crontab files are stored in the /var/spool/cron directory, while on Debian and Ubuntu files are stored in the /var/spool/cron/crontabs directory.

To get a list of all cron jobs for the user you are currently logged in as, use the crontab command:

crontab -l

If the user has set up cron jobs, the content of the user crontabs will be displayed on the screen. Otherwise, the command will print no crontab for <username>.

To list other users cron jobs, use the -u option to specify the user name at the end of the command. For example, to list the cron jobs of the user named “mark” you would use:

sudo crontab -u mark -l

Each user crontab file has 600 permissions and owned by the user. Only root and users with sudo privileges can view other users’ cron jobs.

To find out which users have created cron jobs, list the content of the spool directory as root or sudo user:

sudo ls -1 /var/spool/cron/crontabs

The output will look something like this:


Listing System’s Cron Jobs

/etc/crontab and the files inside the /etc/cron.d directory are system-wide crontab files that can be edited only by the system administrators.

Use cat , less or any text editor to view the content of the files:

cat /etc/crontab /etc/cron.d/*

In most Linux distributions you can also put scripts inside the /etc/cron.{hourly,daily,weekly,monthly} directories, and the scripts are executed every hour/day/week/month.

Each script inside these directories must have execute permission . Otherwise the cron job will not be executed.

For example, to view all the weekly cron jobs you would type:

ls -l /etc/cron.weekly/
-rwxr-xr-x 1 root root 813 Feb 10  2019 man-db

If the output is empty, it means that there are no weekly cron jobs.

Systemd Timers

Systemd timers are unit files that end with *.timer suffix and allow you to run service units based on time.

On Linux distributions using systemd as an init system, the timers are used as an alternative to the standard cron daemon.

To view a list of all systemd timers on your machine run the following command:

systemctl list-timers
NEXT                         LEFT          LAST                         PASSED       UNIT                         ACTIVATES
Sun 2020-02-16 00:00:00 UTC  1h 53min left Sat 2020-02-15 17:04:11 UTC  5h 2min ago  logrotate.timer              logrotate.service
Sun 2020-02-16 00:00:00 UTC  1h 53min left Sat 2020-02-15 17:04:11 UTC  5h 2min ago  man-db.timer                 man-db.service
Sun 2020-02-16 03:50:52 UTC  5h 44min left Sat 2020-02-15 17:04:11 UTC  5h 2min ago  apt-daily.timer              apt-daily.service
Sun 2020-02-16 06:12:38 UTC  8h left       Sat 2020-02-15 17:04:11 UTC  5h 2min ago  apt-daily-upgrade.timer      apt-daily-upgrade.service
Sun 2020-02-16 18:44:56 UTC  20h left      Sat 2020-02-15 17:16:10 UTC  4h 50min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service


We have shown you how to list cron jobs and systemd timers.

Feel free to leave a comment if you have any questions.