2

I want to set Jenkins to run a job every 3rd minute, but not starting at 0. Basically, I have 3 jobs and I want to cycle through them each minute.

The first job I can run every 3rd minute with */3 * * * *. But the second I tried 1/3 * * * * and it failed with hudson.remoting.ProxyException: line 1:2: unexpected token: /

How do I write this expression?

ewok
  • 20,148
  • 51
  • 149
  • 254
  • I believe the problem here is in Jenkins evaluation of cron expression. I am using 0 0/12 * * * to run every day at Noon and Midnight, but am getting the same error the OP is: "unexpected token: /" – timblaktu Mar 02 '20 at 20:10
  • @timblaktu - It looks like Jenkins is sticking close to the [gnu mcron](https://www.gnu.org/software/mcron/manual/html_node/Crontab-file.html#Crontab-file) (and by implication vixie cron) standard, which has the `x-y/z` and `*/z` but doesn't specify `x/z`. (The [IEEE standard](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html) doesn't even allow for the `/` construct at all, just comma-separated lists.) – bto Mar 04 '20 at 16:38

1 Answers1

2

I think you're looking for:

  • job 1: 0-57/3 * * * *
  • job 2: 1-58/3 * * * *
  • job 3: 2-59/3 * * * *

Think of the cron minute entry as meaning "range/step" (or, "run this every step minutes over the minute range start-end)

Reference: I was able to figure it out from this excellent answer, which includes some helpful related links and a more in-depth explanation.

bto
  • 1,619
  • 15
  • 23
  • Then why does cron.help or other cron docs show that */3, 1/3, etc are all valid cron expressions? I believe the problem here is in Jenkins evaluation of cron expression. I am using: 0 0/12 * * * to run every day at Noon and Midnight, but am getting the same error the OP is: "unexpected token: /" – timblaktu Mar 02 '20 at 20:09