How to Find a Fugitive Crontab

cron

A few years ago I setup a cron job to automatically ping a URL every minute as part of a monitoring system (that's oversimplification, but it'll do for this question). Because I'm a horrible person, I didn't document this anywhere.

Today, years later, I started having trouble with the application on the other end of the URL that's being pinged. I fixed it, but then realized, I have no idea where this cron job is coming from.

Is there a way to quickly search through or cat out all the crontabs on a particular system? I have root access so permissions aren't a problem. I've only ever been a user of cron, I've never looked too deeply at its implementation, but my *nix instincts say there has to be a group of text files somewhere that hold all the crontabs. I just don't know where they'd be, and if I dug into it I'd be afraid of finding some, but not all of them, or missing some weird nuance of the system

Also, I realize with root access I could

  1. Get a list of all the users in the system
  2. su as a user
  3. crontab -l
  4. Repeat with all the users

but I'm looking for something a little less manual (and looking to learn something about cron's implementation)

Best Answer

There are only a few places crontabs can hide:

  • /etc/crontab
  • /etc/cron.d/*
  • /etc/crond.{hourly,daily,weekly,monthly}/*
    these are called from /etc/crontab, so maybe an asterisk on this
  • /var/spool/cron/* (sometimes /var/spool/cron/crontabs/*)

Be sure to check at as well, which keeps its jobs in /var/spool/at/ or /var/spool/cron/at*/

Also, instead of

su <user>
crontab -l

Just do this:

crontab -lu <user>
Related Question