Linux List / Display and view all cron jobs

last updated in Categories ,

How do I view currently setup or all running cron jobs under a Linux or Unix-like operating systems?

The cron service searches its spool area (usually /var/spool/cron/crontabs) for crontab files (which are named after user accounts); crontabs found are loaded into memory. cron also reads /etc/crontab, which is in a slightly different format. Additionally, cron reads the files in /etc/cron.d: it treats the files in /etc/cron.d as in the same way as the /etc/crontab file. [donotprint][/donotprint]The intended purpose of /etc/cron.d/ directory feature is to allow packages that require finer control of their scheduling than the /etc/cron.{daily,weekly,monthly} directories to add a crontab file to /etc/cron.d.

Linux View Users Cronjob

Use the following syntax to view vivek users cronjob:

sudo crontab -u userName -l
sudo crontab -u vivek -l

How to Display all jobs in cron / crontab

I run the following as root user:
crontab -l
Linux view all cron jobs command

View Root User Cronjob on Linux

Just type the following command as root user:

crontab -l

OR

sudo crontab -l

Sample outputs:

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
#* * * * *	root /root/bin/master.replication
@reboot /bin/sleep 100;/bin/systemctl restart memcached

How to view /etc/crontab on Linux or Unix

A cronjob can be also run from /etc/crontab file. To view it run the following less command:
# less /etc/crontab
Sample outputs:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
 
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

Linux view daily cronjob

Type the following commands to display daily crontab:

cd /etc/cron.daily/
ls -l
cat filename
cas passwd
Linux view running cron jobs
Linux view running daily cron jobs

Unix view hourly cronjobs

Type the following commands:

cd /etc/cron.hourly/
ls -l
cat filename

How to view Weekly Cron jobs on Linux

Type the following commands:

cd /etc/cron.weekly/
ls -l
cat filename

Command to see monthly Cronjobs / crontabs

Excute the following cat command to see running cron jobs:

cd /etc/cron.monthly/
ls -l
cat filename

View Software (Package) Specific Cronjobs

Run the following commands

cd /etc/cron.d/
ls -l
cat filename
cat renew-ssl-certs

How to Display (List) All Jobs in Cron or Crontab

This entry is 5 of 15 in the Linux Cron Jobs Howto & Tutorial series. Keep reading the rest of the series:
  1. What is cron on a Linux or Unix-like systems?
  2. HowTo: Add Jobs To cron Under Linux or UNIX?
  3. Linux Verify crond Daemon And Cronjobs Are Running
  4. Linux Start Restart and Stop The Cron or Crond Service
  5. Linux: List / Display All Cron Jobs
  6. Linux / UNIX Crontab File Location
  7. Linux / UNIX: Change Crontab Email Settings ( MAILTO )
  8. Disable The Mail Alert By Crontab Command On a Linux or Unix-like Systems
  9. Linux: At What Time Cron Entries In cron.daily, cron.weekly, cron.monthly Run?
  10. Linux Execute Cron Job After System Reboot
  11. Linux / UNIX Setup and Run PHP Script As A Cron Job
  12. How to run crontab job every minute on a Linux or Unix-like system
  13. Run crontab (cron jobs) Every 10 Minutes
  14. Cron Job Script Execution on the Last Day of a Month
  15. Run crontab (cron jobs) every 1 minute

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

10 comment

  1. Thank you for a very good summary. If a cron task is required to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d/ directory.

  2. crontab -l just lists the jobs for the user who ran the command.

    So, to view root’s jobs, you’d either need to be logged in as root or run it with sudo.

  3. There is also very handy script to view all users crontabs. Run it as follows to list all cron jobs for user:

    for u in $(cut -f1 -d: /etc/passwd)
    do 
       echo "*** [$u] ***"
       crontab -u "$u" -l
    done
  4. How do we check running cronjob process.
    I guess, its from ps -ef | grep file.sh

    or any other suggestion.

  5. How does one check the “version” of cron running? How can one know if their cron is a “vixie-style” crontab or not?

    1. Try the following:

      ## debian/ubuntu, see version and man page for syntax ##
       dpkg -p cron
       man cron
      ## RHEL/CentOS specific info ##
       yum info cronie
       man crond
      ## See man page
      
  6. I do this task manually
    ./getConfig ‘indirect’ ‘./(Command task)’ ‘./(Credential.csv’ ‘/usr/cronout/’ (standalone server)
    in command task there is a “cat /etc/ssh/sshd_config” but I saw blank sshd_config even though I can see details about sshd_config when I run those task manually. Can you help me?

    Still, have a question? Get help on our forum!