Mats Andersson
Mats Andersson

Reputation: 397

Cron not working as expected

I have an interesting problem with a cron job. I'm on a server with Cent OS and we're using Vixie cron. All this is very straighforward and i have a backup job that i want to run once every day at 01.00, so i created this simple crontab entry:

* 1 * * * /path/to/my/simpleJob.sh

What happens is this: at 01.00.02, the job runs as expected. Then cron (or something) continues to run the job every minute. Can anyone out there help me out? I have no idea what might be the root cause for this.

/M

Upvotes: 0

Views: 230

Answers (2)

mlbx02
mlbx02

Reputation: 49

The CronSandbox at Dataphyx lets you play about with the date/time values - you see a schedule of runtimes for whatever combination you put in.

Upvotes: 0

fedorqui
fedorqui

Reputation: 289725

The format is:

 +---------------- minute (0 - 59)
 |  +------------- hour (0 - 23)
 |  |  +---------- day of month (1 - 31)
 |  |  |  +------- month (1 - 12)
 |  |  |  |  +---- day of week (0 - 6) (Sunday=0 or 7)
 |  |  |  |  |
 *  *  *  *  *  command to be executed

So in your case being

* 1 * * * /path/to/my/simpleJob.sh

it means at hour 1, any minute.

To have it working just at 1.00, change it to:

0 1 * * * /path/to/my/simpleJob.sh

Upvotes: 3

Related Questions