What are cron jobs?
Cron jobs are routines that execute a script on any given interval. For instance, you may have a script that cleans files from a directory or updates a certain database and need to run that script every few hours. This would be accomplished with a cron job, because the cron job would execute the same script however often you tell it to run.
Cron is the name given to the program that helps UNIX users to run a command or groups of commands in an automated manner at fixed schedules, usually from a script file. It is primarily used for system administrator commands. But in general, it can be used for all purposes. A simple example of it, and also used on a daily basis by everyone, is internet connectivity, email attachment downloads, etc.
In other words, a cron job is used to run an automated and scheduled process of repetitive tasks.
Note: A knowledge of Linux commands is necessary for executing cron jobs effectively.
Cron Job Elements
Usually a cron job has three parts –
- The script that is to be invoked for execution.
- The Linux command that executes the script on a scheduled or repetitive basis.
- The output of the script.
Specific setup instructions are given to the user for most of the scripts that use a cron job. However, when you are uncertain of the instructions, contacting the script’s author before adding the cron job will help.
Cron Job Limits
There are certain limits and restrictions when it comes to running cron jobs. Using certain scripts or commands, a cron job can be run in different ways.
- Shared and Reseller – A cron job cannot be run more than once every 15 minutes.
- VPS and Dedicated Server – You can run a cron job as often as necessary or required.
- cURL, GET, and WGET – cURL, GET and Wget are widely used in cron jobs and by default they are enabled on all servers. No further or extraaction is necessary to activate these functions. Additional information is available here.