Cron is an utility which enables unix-like users to schedule and execute scripts or commands at a specified time and date.
Cron is derived from greek word Chronos which means “Time”.
These cron jobs can be apt for scheduling repetitive tasks like clean up of temporary files, downloading files, running back up scripts at regular intervals.
Each cron job is like one line of a crontab (i,e cron table) file and it will run at scheduled intervals on a given schedule .
Cron is a daemon (a program that runs in background) and needs to be started only once, it will be idle until it is required to be active. The cron deamon or crond will be idle until a time specified to run in the cron tabs.
Cron Job Components:
Majority of cron job includes three components
- Script : The script can be called or executed.
- Command :The command executes the script on the scheduled basis.
- Action :The output or action of the script.
CronTab Commands For Quick Reference
crontab -l : Displays crontab file.
crontab -r : Removes crontab file.
crontab filename : Install filename as your crontab file.
crontab -e : Edit crontab file, or create one if it doesn’t already exist.
crontab -u user : this command allows you to modify or view the crontab file of user.Only administrators can execute this option.