Cron Job is used to execute and run different applications, scripts, commands, and tasks at the specified time and intervals in Linux distributions.
List and Display Current User Cron Jobs with crontab Command
The crontab is the official command in order to manage cron jobs. The crontab command can be also used to list and display current con jobs. The -l option is provided to the crontab command in order to list current user cron jobs.
crontab -l
If the root user executes this command all users cron jobs are printed as the root user has access permission for everything in a Linux system.
List and Display Current User Cron Jobs with /etc/crontab
The cron jobs are stored in the /etc/crontab file. This file can be printed in order to list and display cron jobs. The cat or less commands can be used to print the /etc/crontab file.
cat /etc/crontab
by using the less command.
less /etc/crontab
List and Display Root Cron Jobs with crontab Command
As stated previously crontab command lists the current user cron jobs by default. If we need to list and display the root user cron jobs there are different ways. First, the Sudo command can be used to list root user cron jobs. In the following example, we elevate privileges to the root and then run crontab command with -l option.
sudo crontab -l
An alternative way is logging as the root user. There are different ways to log in as a root user. The terminal or bash can be used to log in as a root user with the “su” command. Alternatively, the GUI or Desktop Environment can be used to log in as root user.
su -
After logged in as root user the regular crontab command can be executed like below.
crontab -l
List and Display Different User Cron Jobs with crontab Command
Another user cron jobs can be listed with the crontab command. The -u option is used to specify the user we want to display jobs. Also, we should have the root privileges which can be provided with the sudo command. In the following example, we will list and display cron jobs of the user “ahmet”.
sudo crontab -l -u ahmet
List and Display Hourly Cron Jobs
Cron Jobs are used to running the different tasks at different dates and times or in different intervals. The cron job provides the /etc/cron.hourly
directory in order to store hourly jobs. Hourly jobs are executed at every hour. The cron jobs are stored as files where the file contents are scripts or commands.
ls -l /etc/cron.hourly
List and Display Daily Cron Jobs
Cron Jobs are used to running the different tasks at different dates and times or in different intervals. The cron job provides the /etc/cron.
daily directory in order to store daily jobs. Daily jobs are executed at every day. The cron jobs are stored as files where the file contents are scripts or commands.
ls -l /etc/cron.daily
List and Display Weekly Cron Jobs
Cron Jobs are used to running the different tasks at different dates and times or in different intervals. The cron job provides the /etc/cron.
weekly directory in order to store weekly jobs. Weekly jobs are executed at every week. The cron jobs are stored as files where the file contents are scripts or commands.
ls -l /etc/cron.weekly
List and Display Monthly Cron Jobs
Cron Jobs are used to running the different tasks at different dates and times or in different intervals. The cron job provides the /etc/cron.
monthly directory in order to store nonthly jobs. Monthly jobs are executed every month. The cron jobs are stored as files where the file contents are scripts or commands.
ls -l /etc/cron.monthly