A Cron Job is primarily used to schedule a command or job in Linux. It permits automating certain commands or scripts in the server to complete the repetitive tasks automatically. It can be set to run by the minute, hour, day of the week, day of the month, month, or the combination of the above mentioned. A Cron job can be set to delete the temporary log every week to avoid the disk space being used by logs which are not necessary. A cron job can also be set up to perform certain functions in Drupal.
Main components of cron job:
- The script to be executed.
- The command to execute the script.
- The action or output of the script, which depends on the action of the script called.
Commonly used crontab commands:
Edit or create a crontab fileone.
Display your crontab file.
Remove your crontab file.
Display the last time you edited your crontab file.
crontab -u user
This option allows you to modify or view the crontab file of user.
Crontab Fields and Allowed Ranges
Scheduling a Job For a Specific Time
The example below illustrates the working of a basic cron job.
Please note that the time field uses 24 hours format. So, for 10 AM use 10, and for 10 PM use 22.
30 10 11 07 * /home/user/backup.sh
This will execute the backup.sh script on 11th July 10:30 AM.
30 – 30th Minute
10 – 10 AM
11 – 11th Day
07 – 7th Month (July)
* – Every day of the week
ServerAdminz is a server support company specialized in Outsourced 24/7 Web Hosting Support, Remote Infrastructure Management, NOC, Cloud and Enterprise Security Services. With over 10+ of years of experience in working with major Data Centers and ISPs with 130+ experienced technicians, we continue to manage more than 49,000 servers from 85+ countries and has bagged 5 international awards.
If you have any queries on how to set up a cron job feel free to leave us a message and our representative will get back to you.[two_third last=”yes” spacing=”yes” center_content=”no” hide_on_mobile=”no” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_position=”all” border_size=”0px” border_color=”” border_style=”” padding=”” margin_top=”” margin_bottom=”” animation_type=”” animation_direction=”” animation_speed=”0.1″ class=”” id=””]