A cron job is a task which is scheduled to run automatically at specified intervals on your server. It is often used for automation of tasks as for example backups, script running, sending emails and system maintenance.
So, a cron job is a Linux scheduler that can run commands or scripts at a particular time.
For example, you can create a task that:
Run every minute
Hourly Run
Run daily, weekly or monthly
A cron job looks like this:* * * * * command to run
Each * is a time span:
Min.
Hour
Day / Month
Month
Weekday
Every minute: * * * * *
Hourly: 0 * * * *
Daily at 12 a.m.: 0 0 * * *
Every Sunday at 2am: 0 2 * * 0
If you have SSH access you can create a cronjob using the following:
crontab -eAdd your cron command then e.g.:
0 0 * * * php /home/user/script.phpSave and exit editor
Most hosting control panels also have a cron job interface:
Go to Cron Jobs
Select time interval (minute/hour/day)
Script command or path
Save settings
Typical uses of cron jobs are:
Automated Backup Tasks
Database Updates
Schedule email send
Clear Cache
Maintenance script is executing...
Always use correct file paths
Make scripts executable
Schedule after testing commands (manually)
Don’t pile heavy tasks on top of each other
Cron jobs are a handy automation tool that allows you to run server tasks automatically at certain times. Cron jobs help you to improve efficiency, reduce manual work and keep your system running smoothly using SSH or control panel.