A Cron Job is basically a LINUX command for scheduling a task (command). Cron Jobs enable you to automate certain commands or scripts on your server to finish repetitive tasks automatically. For example, if you have to take the backup of a file every six hours, you can set this up simply utilizing cPanel's cron jobs feature.
Also, you could set a Cron Job to delete temporary files every week in order to save your disk space from being used up by unnecessary files. Some scripts, like Drupal, could even require you to set up a Cron Job to perform specific functions.
For most Cron Jobs, there are mainly three components present:
1. The script that's to be referred to as or executed.
2. The command that executes the script on a reoccurring basis. This can be typically set within the cPanel.
3. The action or output of the script that depends on what the script being referred to performs. Frequently, scripts termed as a Cron Job modify files or databases, also they can perform other tasks that don't modify data on the server, like sending out email notifications.
Most scripts that need the use of a Cron Job will give you specific instructions on what has to be setup, giving examples on frequent basis.
To get the most out of your cron jobs, here are some of the most valuable tasks you can set them to run.
1. Cron Email
The Cron Email in the cPanel section that allows you to put in an email address you want to send notifications to once the cron jobs are executed.
To specify the email address, here are the steps you need to perform:
Look for the “Email” text box, and put in the email address you want your system to send the notifications to.
Hit the “Update Email” option.
2. Adding Cron Jobs
When you want to create a cron job, make sure you do the following:
Choose your preferred interval at which the cron job should be run at. You can pick from the menus given, or enter a custom value in the text box.
The command that you want the system to execute when running the cron job should be entered in the text box titled “Command.”
Hit the “Add New Cron Job” button.
3. Checking Existing Cron Jobs
If you want to view the cron jobs you have already created in the past, you can do so by heading to the “Current Cron Jobs” option.
4. Revising an Existing Cron Job
When you need to edit an existing cron job, you just need to do these two steps:
Find the cron job for revision in the “Current Cron Jobs” list. Hit the “Edit” button.
Perform the revisions and then click the “Edit Line” option.
5. Deleting/Removing an Existing Cron Job
When you want to get rid of an existing cron job, you just have to:
Locate the cron job you want to remove and then click on the “Delete” option beside it.
Cron jobs, despite running just simple tasks, are very handy, so make sure you make the most out of them.