dennismonsewicz
dennismonsewicz

Reputation: 25542

Working with cronjobs

I am venturing into the world of setting up cronjobs and trying to learn more about the server side of things. In doing so, I have attempted to setup a Cronjob on my server to run two separate Ruby scripts on two separate days.

The Problem: I setup a cronjob to run at noon on Feb 8, 2011 on the 2nd day of the week (Tuesday), but it ran today instead of the 8th.

Cronjobs

# m h  dom mon dow   command
00 12 5 2 6 /usr/local/bin/ruby /home/ubuntu/email_f.rb
00 12 8 2 2 /usr/local/bin/ruby /home/ubuntu/email_g.rb

Am I doing something wrong? The second script is the one that should run on Feb 8, which is next Tuesday, but like I said, it ran today instead.

Upvotes: 2

Views: 216

Answers (1)

mazianni
mazianni

Reputation: 186

I don't have an ubuntu box handy, but the man file on my slackware box says:

If you specify both a day in the month and a day of week, the result is effectively ORd... the crontab entry will be run on the specified day of week and on the specified day in the month.

The Vixie cron on fedora agrees:

*Note: The day of a command’s execution can be specified by two fields — day of month, and day of week. If both fields are restricted (ie, aren’t *), the command will be run when either field matches the current time. For example, "30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.*

Upvotes: 4

Related Questions