Crontab provides an easy way to automate the repeated execution of tasks.
Following directories and files are of importance to know
/etc/cron.allow
/etc/cron.deny
The above two files tells which all users are allowed to run and not run cron jobs
/etc/crontab
This file tells what to run and when
The simplest entry by default is
$ sudo cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
The above is telling that you run-parts will run all the scripts present in cron.hourly directory every hour
cron.daily every day
cron.weekely every week and so on
To simply schedule your job drop your shell script in any of the 4 directories of schedule appropriate for you
The cron will run your job at required time
Last one thing , if you want more granular control of jobs then you can also create own crontab file and run at specific time
Min Hr Day/Month Month Day/Week
30 0 * * * /home/myhome/runThis.sh
The above entry will run runThis.sh every day at 00:30 hours
More more details about crontab you can also read man page
$ crontab man
http://www.vbseo.com/f34/automated-mysql-datestamp-backup-using-cron-via-shell-13426/
Happy Scheduling
No comments:
Post a Comment
Please share your views and comments below.
Thank You.