Linux List / Display and view all cron jobs

Tutorial details Difficulty Easy (rss) Root privileges Yes Requirements None Time 2m

ADVERTISEMENTS



Linux View Users Cronjob

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.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.

Use the following syntax to view vivek users cronjob:

sudo crontab -u userName -l sudo crontab -u vivek -l 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



View Root User Cronjob on Linux

Just type the following command as root user:

crontab -l crontab -l

OR

sudo crontab -l 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 # 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 ) # # /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 cd /etc/cron.daily/ ls -l cat filename cas passwd

Unix view hourly cronjobs

Type the following commands:

cd / etc / cron.hourly / ls -l cat filename 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 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 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 cd /etc/cron.d/ ls -l cat filename cat renew-ssl-certs

Listing users cron jobs when using systemd timers

Systemd comes with its cron system called systemd.timer. It is another option that one can use on systemd based Linux distro. Use the systemctl command as follows to list cron jobs in Linux

systemctl list-timers

Pass the --all option to see loaded but inactive timers, too:

systemctl list-timers --all



What to do when you get a list of all scheduled cron jobs on your system?

Now you know how to list the cron jobs on your Linux or Unix server or VM. Make sure you backup all cron jobs too. Typically I backup the following in directories:

/var/spool/cron/

/var/spool/anacron/

/etc/cron*

You learned how to list, display, and view all current Linux cron jobs. See the following tutorials for more info:

