How to write a simple crontab?

Posted by Jay     15 August, 2008    612 views   

Crontab (normally they call cron job) are scheduler for an user.

Using this, you can schedule jobs for specified interval, like minutes, hours, days,  weeks, and month.

I do not want to provide details description.

Login to linux, say “crontab -e” (without quotes)

Just cut and paste code here.

You are done. As you guess, one job runs every 15 mins, another 20 mins….

####################################################################
#
#min hour day_of_month month day_of_week  user   command
*/15 * * * * /root/crons/denyhack > /dev/null 2>&1
*/20 * * * * /root/crons/denyhack2 > /dev/null 2>&1
*/25 * * * * /root/crons/denyhack3 > /dev/null 2>&1
*/35 * * * * /root/crons/denyhack4 > /dev/null 2>&1

####################################################################

So they way cron works is it looks at its config file, the ‘crontab’ and when the conditions are met for an entry, it will run that entry. What this means is that you will have to write a script for cron to call that does everything you want it to do. If you have any experience with perl, it would probably be a good choice here. Otherwise any other programming language will do.

As far as the actual cron job goes:

* * * * * command to be executed
- – – – -
‘ ‘ ‘ ‘ ‘
‘ ‘ ‘ ‘ +—– day of week (0 – 6) (Sunday=0)
‘ ‘ ‘ +——- month (1 – 12)
‘ ‘ +——— day of month (1 – 31)
‘ +———– hour (0 – 23)
+————- min (0 – 59)

Following Google Searches Lead To This Post: oracle 10g fedora 11

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : Scripts Unix Tags :

Comments

No comments yet.


Leave a comment

(required)

(required)