How would I get a cron job to run every 30 minutes?

前端 未结 6 1237
鱼传尺愫
鱼传尺愫 2020-12-04 07:36

I\'m looking to add a crontab entry to execute a script every 30 minutes, on the hour and 30 minutes past the hour or something close. I have the following, but

6条回答
  •  误落风尘
    2020-12-04 07:55

    crontab does not understand "intervals", it only understands "schedule"

    valid hours: 0-23 -- valid minutes: 0-59

    example #1

    30 * * * * your_command

    this means "run when the minute of each hour is 30" (would run at: 1:30, 2:30, 3:30, etc)

    example #2

    */30 * * * * your_command

    this means "run when the minute of each hour is evenly divisible by 30" (would run at: 1:30, 2:00, 2:30, 3:00, etc)

    example #3

    0,30 * * * * your_command

    this means "run when the minute of each hour is 0 or 30" (would run at: 1:30, 2:00, 2:30, 3:00, etc)

    it's another way to accomplish the same results as example #2

    example #4

    19 * * * * your_command

    this means "run when the minute of each hour is 19" (would run at: 1:19, 2:19, 3:19, etc)

    example #5

    */19 * * * * your_command

    this means "run when the minute of each hour is evenly divisible by 19" (would run at: 1:19, 1:38, 1:57, 2:19, 2:38, 2:57 etc)

    note: several refinements have been made to this post by various users including the author

提交回复
热议问题