Modern versions of Cron allow you to schedule jobs many different ways so when you need to find all of the cron jobs on a server they may be in many places including:
In this guide, you'll learn a trick for finding cron jobs quickly no matter where they are scheduled. As a bonus, we'll show how our free software, CronitorCLI, can make this and other cron management tasks easier for you in the future.
The trick to finding cron jobs quickly is to bypass the familiar user interface of the crontab
command and instead, for this exercise, look under the hood where cron itself store 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.
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
.
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/*
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 when the job is just viewing the crontabs, looking at the files themselves is the easiest way to find every job for every user.
$ cat /var/spool/cron/crontabs/*Redhat, CentOS, Amazon Linux, Suse
$ cat /var/spool/cron/*
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.
A simple and free executable, all you have to do is download and decompress the CronitorCLI binary. You'll be scanning in seconds.
After decompressing, use the list
command to view all cron jobs.
Here there are 8 cron jobs in two crontabs. If there were 400 cron jobs in 40 crontabs, all of them would be listed.
CronitorCLI includes other great free tools like select
and shell
to run commands the way cron does.
Cronitor automatically finds and monitors cron jobs. Complete your setup in minutes.