-1

Is it possible to run a job for 2 hours at a specific time? So lets say I want to run wget command that calls/hits an endpoint in my web app for 2 consecutive hours in a day. Meaning that every single minute I want to hit this end point for the allocated 2 hour time slot. How do I do this?

user79356
  • 627
  • 1
  • 8
  • 13

2 Answers2

2
* 1-3 * * *  /path/to/command

means run your command at every minute from 1:00am to 3:59am

to run the command every minute between the hours of 1am and 3am you need run

* 1-2 * * *  /path/to/command
ray
  • 471
  • 3
  • 3
1

Let's say you want to run the command every minute between the hours of 1am and 3am:

* 1-2 * * *  /path/to/command

Add that to your crontab with crontab -e

EDIT: originally had this as 1-3, which as @ruifeng pointed out, means run your command at every minute from 1:00am to 3:59am.

xofer
  • 3,052
  • 12
  • 19