How can get a list of all scheduled cron jobs on my machine?

  • My sysadmin has set up a bunch of cron jobs on my machine. I'd like to know exactly what is scheduled for what time. How can I get that list?

    This isn't the answer to the question, but just a note on best practices. One _can_ configure these as per-user cron jobs for `root` or `apache` or whatever, but one _should_ use `/etc/crontab` or (better, in most distros) `/etc/cron.d` and `/etc/cron.[timeframe]`.

    I have posted a script which automates this to a useful degree at: - https://stackoverflow.com/questions/134906/how-do-i-list-all-cron-jobs-for-all-users/53892185#53892185 It's not perfect but probably covers 90% of the needs. It is a good example of what not to write in bash.

  • jsbillings

    jsbillings Correct answer

    10 years ago

    Depending on how your linux system is set up, you can look in:

    • /var/spool/cron/* (user crontabs)
    • /etc/crontab (system-wide crontab)

    also, many distros have:

    • /etc/cron.d/* These configurations have the same syntax as /etc/crontab

    • /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, /etc/cron.monthly

    These are simply directories that contain executables that are executed hourly, daily, weekly or monthly, per their directory name.

    On top of that, you can have at jobs (check /var/spool/at/*), anacron (/etc/anacrontab and /var/spool/anacron/*) and probably others I'm forgetting.

    Thanks, I found them in `/etc/cron.daily`. How does that `daily` file work? What time will the daily jobs run? On my machine they seem to run around noon, but it'd like to tell my sysadmin how to change that to midnight instead.

    cron.daily is called from `/etc/crontab`, e.g. on my Ubuntu system it's: `25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )` which means 6:25 am.

    cron.daily is called from /etc/crontab on my RHEL5 system too, if you'd like more data points.

    On newer Fedora (and probably RHEL6 -- haven't looked yet), the `cronie` daemon takes care of those using the configuration in `/etc/anacrontab`.

    Sometimes it's in `/var/cron` too.

    I'm using `at`jobs but `/var/spool/at/*` does not exists.

    I don't think you're forgetting any. A very complete listing. Thanks!

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM