How to List, Display, & View all Current Cron Jobs in Linux

Introduction

Cron jobs are an essential part of Linux systems. They allow you to schedule tasks to run at specific times or intervals. This tutorial will show you how to list, display, and view all current cron jobs in Linux. We will cover the different commands and options available to list, display, and view cron jobs. We will also discuss how to create and delete cron jobs. By the end of this tutorial, you will have a better understanding of how to manage cron jobs in Linux.

How to List, Display, & View all Current Cron Jobs in Linux

1. List Cron Jobs

To list all cron jobs, open a terminal window and type the following command:

crontab -l

This will list all the cron jobs that are currently set up on the system.

2. Display Cron Jobs

To display the contents of a cron job, use the following command:

crontab -e

This will open the crontab file in a text editor, allowing you to view the contents of the cron job.

3. View Cron Jobs

To view the output of a cron job, use the following command:

tail -f /var/log/cron

This will display the output of the cron job in the terminal window.

Introduction

Cron is a Linux utility for scheduling scripts and commands. This guide will show you several options to view current cron jobs scheduled in the crontab list.

how to display cron jobs in linux

Prerequisites

  • A user account with sudo privileges
  • Access to a terminal window / command line (Ctrl+Alt+T, Ctrl+Alt+F2)

Listing Cron Jobs in Linux

How to List all Active Cron Jobs Running

To list all scheduled cron jobs for the current user, enter:

crontab -l
list all scheduled cron jobs

Cron jobs are typically located in the spool directories. They are stored in tables called crontabs. You can find them in /var/spool/cron/crontabs. The tables contain the cron jobs for all users, except the root user.

The root user can use the crontab for the whole system.

To display contents of the root user’s crontab, use the less command:

less /etc/crontab

The system returns an output like the following:

# /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 )

The /etc/crontab file can be edited using a text editor like nano:

sudo nano /etc/crontab

In RedHat-based systems, this file is located at /etc/cron.d.

The /etc/ directory has additional cron subdirectories to organize hourly, daily, weekly, and monthly tasks. The ls (list) command displays files and directories. Use the -la option to list all entries in long format.

View Cron Jobs by User

To list cron jobs that belong to a specific user, run the following command:

sudo crontab -u [username] -l

Replace [username] with the actual username you’re viewing.

How to List Hourly Cron Jobs

To list hourly cron jobs enter the following in the terminal window:

ls -la /etc/cron.hourly

The output should appear similar to this:

output of list hourly cron jobs

How to List Daily Cron Jobs

To list daily cron jobs, enter the command:

ls -la /etc/cron.daily

The results will look similar to the following output:

a listing of daily cron jobs currently running

How to Display Weekly Cron Jobs

To display weekly cron jobs:

ls -la /etc/cron.weekly

The results will look something like the following:

total 28
drwxr-xr-x  2 root root 4096 Apr 24 20:46 .
drwxr-xr-x 96 root root 4096 May 19 17:12 ..
-rw-r--r--  1 root root  102 Feb  9  2013 .placeholder
-rwxr-xr-x  1 root root  730 Feb 23  2014 apt-xapian-index
-rwxr-xr-x  1 root root  427 Apr 16  2014 fstrim
-rwxr-xr-x  1 root root  771 Sep 23  2014 man-db
-rwxr-xr-x  1 root root  211 Mar 27  2017 update-notifier-common

How to List Monthly Cron Jobs

To display monthly cron jobs use the ls command in this format:

ls -la /etc/cron.monthly

The results appear as:

total 12
drwxr-xr-x  2 root root 4096 Apr 24 20:44 .
drwxr-xr-x 96 root root 4096 May 19 17:12 ..
-rw-r--r--  1 root root  102 Feb  9  2013 .placeholder

View Software Specific Cron Jobs

To view software specefic cron tasks, start by viewing a list of cron tasks:

cd /etc/cron/daily
ls -l

Use the cat command to display the contents of update-notifier-common:

cat update-notifier-common

The results will look similar to:

#!/bin/sh

set -e

[ -x /usr/lib/update-notifier/package-data-downloader ] || exit 0

# Try to rerun any package data downloads that failed at package install time.

/usr/lib/update-notifier/package-data-downloader

Note: You should also learn more about Linux at command, another useful tool for scheduling jobs.

Conclusion

Now you know how to navigate through the cron jobs on your machine. Cron is a helpful utility for scheduling tasks such as running a job at reboot. Use the commands from this guide to sort and display tasks scheduled through the cron tool.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?