Nishant
Nishant

Reputation: 358

How to executing cron one minute after midnight every day?

I want to execute cron every day on midnight at time 00:01 Hrs. Is the following cron time correct?

1 0 * * * *

Upvotes: 12

Views: 21578

Answers (4)

Chirag Shah
Chirag Shah

Reputation: 373

0 1 0 * * ?

or

1 0 * * *

You can generate crons example with https://www.freeformatter.com/cron-expression-generator-quartz.html

Upvotes: -1

A. Smith
A. Smith

Reputation: 51

1 0 * * * /mydir/myscript <-- Correct 1 minute after midnight

1 0 * * * * <--- Incorrect, Syntax Error

Upvotes: 5

Yes the cron time is correct.

1 0 * * * /mydir/myscript 

should be your cron entry.

Each cron entry consists of six fields, in the following order:

minute(s) hour(s) day(s) month(s) weekday(s) command(s)
 0-59      0-23    1-31    1-12     0-6

Upvotes: 20

Martin Schapendonk
Martin Schapendonk

Reputation: 13486

Let's get the definitions straight: cron is a daemon that is designed to run continuously and execute commands at specified intervals when you tell it to.

To do that, it needs two things: an interval and a command.

Your example has a valid interval, but is missing a command to execute one minute after midnight:

1 0 * * * * /path/to/executable/or/script/here

Upvotes: -2

Related Questions