What is a Cron Job?
A cron job is a scheduled task that is set to run at predefined times or intervals. It is typically used to automate system maintenance or administration. A cron job can be set to run a script file at a specific time or interval.
Scheduling tasks to run at specific times is a common system administration practice. Cron is a time-based job scheduler in Unix-like computer operating systems. Users can schedule jobs to run periodically at specific times, dates, or intervals. These jobs are typically initiated by cron, a daemon that runs in the background and executes these jobs on behalf of the user. In this article, we will discuss what cron is, how it works, and some common uses for it.
Setting-up a a Cron Job in cPanel:
To create a new cron job, follow these steps.
Step-1: Log in to cPanel, scroll down to the Advanced section and click the Cron Jobs icon.
Step-2: Scroll down to the Add New Cron Job section. You can either select from the Common Settings drop down menus or fill out your own custom values. Fill out the form as follows:
- Common Settings: This option allows you to select a preset interval for your cron job to run.
If you have not chosen one of the preset Common Settings, choose from the other options:
- Minute: Either enter a custom value or select a preset value from the Common Settings.
- Hour: Either enter a custom value or select a preset value from the Common Settings.
- Day: Either enter a custom value or select a preset value from the Common Settings.
- Month: Either enter a custom value or select a preset value from the Common Settings.
- Weekday: Either enter a custom value or select a preset value from the Common Settings.
The following example shows a job set up to run twice daily.
Step-3: Type the command you want to run in the Command input field and then click Add New Cron Job.
An alert will appear to confirm that the job has been added.
Cron Job E-mail Notification:
cPanel by default sends you a notification whenever a scheduled cron job is executed. It also inserts the readout or the command’s outcome into the notification. The default notification email for the task is the email address that is assigned to your system account, but you may alter this email address as well. To alter your own email from which you want to obtain cron notification, initially go to the Cron Job interface and go to Cron Email. After that, enter your new email address in that where you will wish to receive cron notification.
The following video will guide you on How to create Cronjob via cPanel with WebCare360