How to Get a List of All Scheduled Cron Jobs on a Machine?

In Linux, cron is a job scheduler that schedules commands or scripts to run at specific times. It automates tasks based on minute, hour, day, month and day of the week. It has various applications such as running backups, generating reports, and updating databases on a regular basis. It saves time and decreases the errors risk when performing these tasks manually.

This guide will demonstrate the method to list all scheduled cron jobs on the current Linux machine.

Note: If cron jobs are not scheduled on the machine, follow the link to schedule jobs according to requirement.

Get a List of All Scheduled Cron Jobs on a Machine

A scheduled cron job is a type of cron job that is set to run at a specified date and time. To get a list of all scheduled cron jobs on Linux, follow the below instructions:

Example 1: Scheduled Cron Jobs of Current Log-in User

The crontab command is used to edit and view the cron jobs on a Linux machine. To view the list of all scheduled cron jobs, execute the “crontab” command with the “l” option:

$ crontab -l

This command displays the two scheduled cron jobs for the current user in the terminal.

Example 2: Scheduled Cron Jobs Root User (System-Wide)

To view the system-wide cron jobs, specify the “root” user with the “u” option. It displays the system-wide cron jobs in the terminal:

$ sudo crontab -l -u root

This command displays the cron jobs for the root user in the terminal.

Example 3: Monthly Scheduled Cron Jobs

To get the list of monthly scheduled cron tabs, execute the “ls -la” command with the “/etc/cron.monthly” file:

$ ls -la /etc/cron.monthly

The output returns the cron jobs that are set based on the month.

Example 4: Weekly Scheduled Cron Jobs

The scheduled cron jobs set on a weekly basis can be visualized by specifying the “/etc/cron.weekly” in the following command:

$ ls -la /etc/cron.weekly

The output shows that weekly cron job in the terminal.

Example 5: Daily Scheduled Cron Jobs

To present the list of all scheduled cron jobs that are set daily basis is possible with the following command:

$ ls -la /etc/cron.daily

The above displays return the cron scheduled jobs that are set on a daily basis.

Example 6: Hourly Scheduled Cron Jobs

Linux assists users to visualize the scheduled cron jobs hourly basis with the following command:

$ ls -la /etc/cron.hourly

The output returns the cron scheduled jobs that are set hourly.

Conclusion

Linux offers the “crontab -l” command to get a list of all scheduled cron jobs from the current user on a machine. To present the cron jobs of a specific user or root, execute the “sudo crontab -l -u <username>” command. Additionally, scheduled cron jobs can be displayed on the basis of monthly, weekly, daily, and hourly. This article has briefly explained getting a list of all scheduled cron jobs on a system.