The cron in Linux is the same as the Time Schedule in Windows and has the ability to set the execution of commands at the specified time. In this article, we will install the cron in Linux and then we will get to know its command.
Cron in Linux is a scheduling system for executing scripts and commands that will act like the Time Schedule in Microsoft Windows.
Cron in Linux
With Cron, known as the Crontab command in Linux, you will be able to add commands under a shell script or as normal, and request execution at the desired time.
The Crontab tool is now available by default on most Linux distributions, but it may not be installed by default with minimal versions, etc.
How to install cron in RHEH / CentOS Linux
To install the crontab tool in RHEL and Centos and other distributions based on these two Linux versions run the following command:
yum install -y cronie
How to install cron in Ubuntu / Debian Linux
In Ubuntu and Debian and other distributions based on them, you can install the crontab tool with the following command:
apt-get install –y cron
At this point, when you install the cron, you can work with crontab commands.
How to work with crontab commands in Linux
In this article, we want to teach you basic crontab commands and in the other article, we will teach you how to work with Cron.
- view preconfigured Crons in Linux
To view all of the jobs configured in cron, you can use the “-l” flag. run the following command:
2. Add a job in cron
To add a job or new jobs in cron or single delete them you can use the “-e” flag after the command to do your operation as an editor.
3. Delete all of the predefined jobs in cron
You can delete jobs in the cron by using the “-r” flag.
Note: remember running the following command, delete all of the predefined jobs in cron.
crontab -i -r
crontab -u orcacore -l
crontab -u olivia -e