Cron is the task scheduler in linux based system. Any user can add their job by editing crontab. The job runs at the time specified by the user.
To add a job
1)type crontab -e in the shell
2)Specify hour, minute, date of month, month, day of the week (as required)
3)Specify the command (Eg. echo "happi Bday"|sendmail "email@example.com"
4)save with :wq and exit
The cron will get the job done for you at the time scheduled by you
Algo behind Cron
Initially cron sleeps for 1 minute and then checks for any process in the queue. If so, does the job and then sleeps for 1 min. This naive method is not scaleable.
Then the jobs are put in event list. The head will be the recent most process to be completed in the future. The cron sleeps till the head is scheduled. Once it discharges the head, its sleeping time becomes (next head's time-now time). It cant sleep without taking into account new entries. So a SIGHUP interrupt will wake the sleeping cron tab to readjust its sleeping time once a new job is added.