Posts

How to Set a Cronjob in Linux

Introduction

A crontab is a simple text file with a list of commands meant to be run at specified times. It is edited with a command-line utility. These commands (and their run times) are then controlled by the cron daemon, which executes them in the system background. Each user has a crontab file which specifies the actions and times at which they should be executed, these jobs will run regardless of whether the user is actually logged into the system. There is also a root crontab for tasks requiring administrative privileges. This system crontab allows scheduling of system wide tasks (such as log rotations and system database updates).

Syntax

Minutes      Hours       Day-of-Month        Month-field         Day-of-Week        /path/to/Command

Set Cronjob

To set the cronjob that runs every 5 minutes

# crontab -e
*/5 * * * * /root/backup.sh