How do I set up a cron job?

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.

What is a cron job?

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:

Format of cron job

A cron job looks like this:
* * * * * command to run

Each * is a time span:

Example cron schedules

How to set up a cron job (using SSH)

If you have SSH access you can create a cronjob using the following:

crontab -e

Add your cron command then e.g.:

0 0 * * * php /home/user/script.php

Save and exit editor

How to setup a cron job (via control panel)

Most hosting control panels also have a cron job interface:

Typical Use Cases for Cron Jobs

Typical uses of cron jobs are:

Notes of importance

Conclusion

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.