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

March 21, 2024

Introduction

Cron is a Linux utility for scheduling tasks that automatically run at specific intervals on Unix-like operating systems. This allows users to automate repetitive tasks such as backups, updates, and data processing without manual intervention.

This guide will show you several options to view current cron jobs scheduled in the crontab list.

How to display cron jobs in Linux - a tutorial.

Prerequisites

  • A user account with root privileges.
  • Access to a terminal window (Ctrl+Alt+T).

Listing Cron Jobs in Linux

Cron jobs are located in the spool directories, in tables called crontabs. Their location varies across different distributions. In Ubuntu, the tables for all users are in /var/spool/cron/crontabs, except for the root user, whose cron jobs are located in /etc/crontab.

The /etc/crontab file contains a list of system-wide root cron jobs. To view the list, use any text editor or utility like catmore, or less. For example:

cat /etc/crontab
Listing system-wide cron jobs in Linux.

The sections below show several different methods for listing cron jobs in Linux.

List All Active Cron Jobs

Knowing how to list all active cron jobs is crucial for system administrators. The easiest way to list all active cron jobs for the current user is via the cron utility.

Run the following command to list all scheduled cron jobs for the current user:

crontab -l
Listing the scheduled tasks for the current user.

The output shows a list of cron jobs for the current user. If the current user has no scheduled jobs, the system displays a message saying no crontab for [user].

The output shows all the cron jobs on the system created by the root user.

View Cron Jobs by User

By listing cron jobs for each user, you can monitor scheduled tasks and identify any issues or misconfigurations. Reviewing user-specific cron jobs helps detect unauthorized or suspicious tasks to ensure that only authorized users have scheduled jobs. This way, you reduce the risk of security breaches.

To list cron jobs that belong to a specific user, use the following syntax:

sudo crontab -u [username] -l

Replace [username] with the actual username you want to view the jobs for. For example:

Listing cron jobs for a specific user in Linux.

The output shows all the cron jobs for the specified user.

List Hourly Cron Jobs

Hourly cron jobs provide a way to automate tasks at regular intervals, ensuring the timely execution of critical processes and efficient resource management. To list hourly cron jobs, run the following command:

ls -la /etc/cron.hourly
Listing hourly cron jobs.

The output shows all the scheduled hourly tasks on your system.

List Daily Cron Jobs

Daily cron jobs usually handle essential tasks like data backups and log rotation. They help create daily reports or perform data analytics tasks automatically. To list daily cron jobs, run the command below:

ls -la /etc/cron.daily
Listing daily cron jobs.

The output is a list of all daily cron jobs on your system.

List Weekly Cron Jobs

Weekly cron jobs are a convenient way to automate recurring tasks on a weekly basis, ensuring their consistent execution. An example of a weekly cron job is a full system backup every Sunday night.

Run the command below to display weekly cron jobs:

ls -la /etc/cron.weekly
Listing all weekly cron jobs in Linux.

The output shows all the cron jobs within the weekly cron jobs directory.

List Monthly Cron Jobs

Monthly cron jobs are advantageous for automating tasks that need to occur once a month, such as system backups, report generation, or database maintenance. To display monthly cron jobs, use the command below:

ls -la /etc/cron.monthly
Listing the monthly cron jobs in Ubuntu.

The output lists all the cron jobs within the directory.

View Software-Specific Cron Jobs

Software-specific cron jobs are scheduled tasks that run periodically to automate specific software-related processes. These tasks are tailored to the needs of particular applications or services. Examples include daily database backups, weekly log rotation, monthly cache clearing, scheduled reports, and indexing/search updates.

To view software-specific cron tasks, list the contents of the cron.d directory:

ls -l /etc/cron.d
Viewing software-specific cron jobs in Linux.

You can use the cat command or a text editor to display the contents of the files in the directory and see the details for each cron job.

Note: Learn more about the Linux at command, another useful tool for scheduling jobs.

Conclusion

Now you know how to view 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.

Next, learn about cron expressions or, if you are using a different OS, see how to set up a cron job on macOS and on Windows.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Set Up a Cron Job in Linux
January 31, 2024

Cron jobs allow you to schedule and automate recurring tasks on your Linux system. They are especially useful...
Read more
Chown Command: Change Owner of File in Linux
October 3, 2024

The chown command changes user ownership of a file, directory, or link in Linux. Every file is associated...
Read more
How to List Users in Linux, List all Users Command
August 4, 2022

Linux OS is unique because of its multiuser characteristic. It allows multiple users on one system, at the...
Read more
How To Use grep Command In Linux/UNIX
February 29, 2024

This guide details the most useful grep commands for Linux / Unix systems. After going through all the...
Read more