Вопрос

How do you run a cron job every minute only between office hours(10 am to 5pm)

I checked this thread Run a cron job every minute only on specific hours? but it doesn't answer my questions.

Это было полезно?

Решение

This should be correct:

* 10-16 * * 1-5 /path/to/my-script

So every single minute, between and including 10am and 5pm, every day in every month that is a day between and including monday to friday. Obviously "office hours" is a fuzzy expression, many people have other schedules ;-)

Unfortunately I fail to see an easy solution to get the script executed also exactly on 5pm...

Другие советы

* 10-16 * * * /path/to/executable/file argument_1 argument_2

Yes, you can define hours range.

Someone tried to edit my answer but as documentation says hours in range are inclusive http://team.macnn.com/drafts/crontab_defs.html so don't change 16 to 17.

It does,

Access your shell script and add the following

  * 10-17 * * *

This means run every min, between these hours, on every day, of every month etc

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top