List all cron jobs for all users
Modern versions of cron allow you to schedule jobs in many different ways. When you need to find cron jobs on a server they may be in many places including:
- Each user's individual crontab
- The system crontab
- The system cron drop-in directory
In this guide, you'll learn a handy trick to quickly find cron jobs, no matter where they are scheduled. We'll also show how our free tool, CronitorCLI, can make this and other cron management tasks easier in the future.
Finding cron jobs quickly
The trick to finding cron jobs quickly is to bypass the familiar user interface of the crontab
command, and instead look under the hood where cron itself stores this data. Before you begin, you will need elevated root
or sudo
privileges to list jobs other than your own. With that arranged, begin your 3-stop tour.
1. The system crontab
The first place to look is the system crontab. Only users with privileged access can write here and this will often contain cron jobs that support system-level functions.
$ cat /etc/crontab
0 0 * * * dataproc create-rollups.py
When scheduling jobs in this and other system-level crontab files the run-as user is listed after the schedule. This job as run as user dataproc
.
2. The system drop-in directory
A more modern and preferred way to scheduling system-level cron jobs, the crontab drop-in directory at /etc/cron.d
may contain crontab files that each can have multiple cron jobs.
Display the contents of all files easily:
$ cat /etc/cron.d/*
3. Each user's crontab
As a rule, you should always use crontab -e
and never modify crontab files directly. Doing so ensures your changes are valid and picked-up by the cron daemon. But if you are just viewing the crontabs, looking at the files themselves is the easiest way to find every job for every user.
Ubuntu/Debian
$ cat /var/spool/cron/crontabs/*
Redhat, CentOS, Amazon Linux, Suse
$ cat /var/spool/cron/*
An easier way to manage cron jobs
In addition to finding cron jobs our open-source software, CronitorCLI, can take the pain from cron job testing and debugging. Installing is free and easy, and you don't have to use our monitoring service to use many of its features.
1. Download CronitorCLI
A simple and free executable, all you have to do is download and decompress the CronitorCLI binary. You'll be scanning in seconds.
CronitorCLI Installation Guide
2. Listing all cron jobs for all users in a single command
After decompressing, use the list
command to view all cron jobs.
In this example there are 8 cron jobs in two crontabs. If there were 400 cron jobs in 40 crontabs, all of them would be listed.
3. Easily run any command the way cron does
CronitorCLI includes other great free tools like select
and shell
to run commands the way cron does.