<p>I believe your issue is the use of * * * * *.</p>
<p>The <a href="https://github.com/jenkinsci/parameterized-scheduler-plugin/blob/master/README.md" rel="nofollow noreferrer">parameterized-scheduler-plugin</a> example has two different times specified.</p>
<pre><code>#lets run against the integration environment at 15 past the hour
15 * * * * % env=int
#run QA too
30 * * * % env=qa
</code></pre>
<p>So one job runs <code>@15</code> and one <code>@30</code>.</p>
<p>Yours specify the same time, so only the first is executed.</p>
<p>You could try the random time parameter <code>&quot;H&quot;</code> or fix some different interval on each.</p>
<p>Or, it does say &quot;Leave a space. Put in a %. Then add the name=value pairs&quot;. So maybe it's <code>cronexp space percent space name=value</code> ?</p>
<p>OR you could just copy the job job and schedule two separate jobs w/fixed parameter.
But Jenkins does sound like the wrong tool for this.</p>
<p>The above will address why only the 1st line was executed.</p>
<p><strong>NOTE</strong> :There is a known issue attemptimg to to every minute, see <a href="https://issues.jenkins-ci.org/browse/JENKINS-22129" rel="nofollow noreferrer">JENKINS-22129</a> H/2 will run every 2 minutes, but H/1 will run every hour.</p>

CC BY-SA 4.0
2020-06-25T10:17:04.243Z
2020-06-26T09:01:15.883Z
2020-06-26T09:01:15.883Z
Ian W
<p>I'm trying to use Jenkins to run a small monitoring script every minute on two separate ECS clusters.
In the text box that opens when you enable &quot;Build periodically with parameters&quot; I wrote:</p>
<blockquote>
<p>* * * * * %CLUSTER=Cluster1;</p>
</blockquote>
<blockquote>
<p>* * * * * %CLUSTER=Cluster2;</p>
</blockquote>
<p>This works fine for Cluster1 but it does not run for Cluster2. It does not fail, it just doesn't run. If you switch the lines it works for Cluster2 (which is now at the top) but not for Cluster1. I made sure the node it runs on has enough runners, and that &quot;Execute concurrent builds if necessary&quot; is enabled. The closest thing I found while googling is <a href="https://stackoverflow.com/questions/12479973/crontab-executes-only-first-line">this</a>, and I checked but there is a blank line after these and adding another or removing it or adding a space between them does not help.</p>
<p>I have a bad workaround which is just squeezing both runs in an unparametrized build and that works but it is inflexible.</p>
<p>So to reiterate the question, why does Jenkins not run concurrent builds from cron, and what can I do to change that?</p>
<p>Thanks.</p>
<p><strong>EDIT:</strong></p>
<p>When you insert a cron schedule of * * * * *, Jenkins posts the following:</p>
<blockquote>
<p>Do you really mean &quot;every minute&quot; when you say &quot;* * * * *&quot;? Perhaps you meant &quot;H * * * *&quot; to poll once per hour.</p>
</blockquote>
<p>As I need it to be on a per minute basis this is (for the 1st one, but not for the 2nd) the desired result.
Based on Ian W's suggestion to do replace the schedule from &quot;* * * * * &quot; to &quot;H/2 * * * *&quot;. I checked it but this still led to only the 1st one being run, and would have caused it to run every other minute and not every minute as intended.
H/1 doesn't run at all, and H/0.5 returns an error of</p>
<blockquote>
<p>Invalid input: &quot;H/0.5 * * * * %CLUSTER=Cluster1;&quot;: line 2:3: step must be positive, but found 0</p>
</blockquote>
<p>I also tried H/1.1 but that returned:</p>
<blockquote>
<p>Invalid input: &quot;H/1.1 * * * * %CLUSTER=Cluster1;&quot;: line 2:4: unexpected char: '.'</p>
</blockquote>
<p>The closest I got so far was staggering the cron jobs like so:</p>
<blockquote>
<p>H/2 * * * * %CLUSTER=Cluster1;</p>
</blockquote>
<blockquote>
<p>* * * * * %CLUSTER=Cluster2;</p>
</blockquote>
<p>Which caused both jobs to run every 2 minutes.</p>
<p>BTW, the Jenkins version is 2.204.1, the Parametrized Scheduler plugin is on version 0.8, if any other plugins are relevant I can post their versions as well.</p>

CC BY-SA 4.0
2020-06-25T05:01:04.043Z
This doesn't seem like a use case that Jenkins is intended for... Is there a reason you aren't running the cron jobs on the clusters themselves, or from a container that you deploy in a separate cluster? Or better yet, use a service like AWS Lambda to periodically execute your script every minute.
Preston Martin
CC BY-SA 4.0
2020-06-25T08:38:22.600Z
@PrestonM, it's better for this task than just a cron job on some server because it's centralized and everyone will know where to look, but mostly it's because of an organizational thing. The QA dept. here know how to work with Jenkins but claim they are too busy to be instructed on proper use of AWS (or ELK, or...). As I need it to be accessible to them I put it where they know to look.
Uberhumus
CC BY-SA 4.0
2020-06-26T07:42:03.840Z
There is a known issue attemptimg to to every minute, see [JENKINS-22129](https://issues.jenkins-ci.org/plugins/servlet/mobile#issue/JENKINS-22129). H/2 will run every 2 minutes, but H/1 will run every hour.
Ian W
CC BY-SA 4.0
2020-06-26T07:45:42.610Z
@IanW That's true, but doing * * * * *, runs every minute. That bug is unrelated.
Uberhumus
CC BY-SA 4.0
2020-06-26T07:51:14.950Z
OK, so you can't have two lines (with parameters) that run at the same time as it only takes the first one. You can't use H/1 as there no random interval in minute increments. Tje leaves you stuck. So, make 2 jobs, with  * * * * *, and a hard-coded env.
Ian W
CC BY-SA 4.0
2020-06-26T07:52:28.323Z
@IanW Not sure I understand. Can you explain?
Uberhumus
CC BY-SA 4.0
2020-06-26T07:56:15.580Z
@IanW That's very close to the workaround we're currently using. :) I'm looking for a more elegant solution, and maybe an explanation of why this behavior occurs.
Uberhumus
CC BY-SA 4.0
2020-06-26T08:22:57.187Z
If you want an explanation, the best I can say is there has been an Open issue for 5 years where 2 Cloudbees (Jenkins sponsor) employees, one of whom is the senior maintainer and the other has been supporting Jenkins since 2008 can't come to an agreement on if it's wrong or whether to fix. Go with your workaround or contribute to the issue. Good luck.
Ian W
CC BY-SA 4.0
2020-06-26T08:24:47.357Z
@IanW Link to it in your answer and I'll accept it. Thanks!
Uberhumus
CC BY-SA 4.0
2020-06-26T09:02:27.833Z
Had added but link needed login. Fixed up.
Ian W
CC BY-SA 4.0
2021-08-11T23:00:34.693Z
I think you're "doing it wrong" scheduling a job to run every minute is quite a burden on all but an unladen Jenkins. Why not run the job once every 30 minutes, but alter the job to process Cluster1, then Cluster2 then sleep for a minute... and repeat.
Steven the Easily Amused
<jenkins>
Jenkins cron works only for the 1st line
Uberhumus
# Jenkins cron works only for the 1st line

(Asked by: username_0 on 2020-06-24)

I'm trying to use Jenkins to run a small monitoring script every minute on two separate ECS clusters.
In the text box that opens when you enable "Build periodically with parameters" I wrote:

> \* \* \* \* \* %CLUSTER=Cluster1;

> \* \* \* \* \* %CLUSTER=Cluster2;

This works fine for Cluster1 but it does not run for Cluster2. It does not fail, it just doesn't run. If you switch the lines it works for Cluster2 (which is now at the top) but not for Cluster1. I made sure the node it runs on has enough runners, and that "Execute concurrent builds if necessary" is enabled. The closest thing I found while googling is [this](https://stackoverflow.com/questions/12479973/crontab-executes-only-first-line), and I checked but there is a blank line after these and adding another or removing it or adding a space between them does not help.

I have a bad workaround which is just squeezing both runs in an unparametrized build and that works but it is inflexible.

So to reiterate the question, why does Jenkins not run concurrent builds from cron, and what can I do to change that?

Thanks.

**EDIT:**

When you insert a cron schedule of \* \* \* \* \*, Jenkins posts the following:

> Do you really mean "every minute" when you say "\* \* \* \* \*"? Perhaps you meant "H \* \* \* \*" to poll once per hour.

As I need it to be on a per minute basis this is (for the 1st one, but not for the 2nd) the desired result.
Based on username_2's suggestion to do replace the schedule from "\* \* \* \* \* " to "H/2 \* \* \* \*". I checked it but this still led to only the 1st one being run, and would have caused it to run every other minute and not every minute as intended.
H/1 doesn't run at all, and H/0.5 returns an error of

> Invalid input: "H/0.5 \* \* \* \* %CLUSTER=Cluster1;": line 2:3: step must be positive, but found 0

I also tried H/1.1 but that returned:

> Invalid input: "H/1.1 \* \* \* \* %CLUSTER=Cluster1;": line 2:4: unexpected char: '.'

The closest I got so far was staggering the cron jobs like so:

> H/2 \* \* \* \* %CLUSTER=Cluster1;

> \* \* \* \* \* %CLUSTER=Cluster2;

Which caused both jobs to run every 2 minutes.

BTW, the Jenkins version is 2.204.1, the Parametrized Scheduler plugin is on version 0.8, if any other plugins are relevant I can post their versions as well.

**Tags:** jenkins

> **Comments:**
> **username_1**: This doesn't seem like a use case that Jenkins is intended for... Is there a reason you aren't running the cron jobs on the clusters themselves, or from a container that you deploy in a separate cluster? Or better yet, use a service like AWS Lambda to periodically execute your script every minute.  
> **username_0**: @PrestonM, it's better for this task than just a cron job on some server because it's centralized and everyone will know where to look, but mostly it's because of an organizational thing. The QA dept. here know how to work with Jenkins but claim they are too busy to be instructed on proper use of AWS (or ELK, or...). As I need it to be accessible to them I put it where they know to look.  
> **username_2**: There is a known issue attemptimg to to every minute, see [JENKINS-22129](https://issues.jenkins-ci.org/plugins/servlet/mobile#issue/JENKINS-22129). H/2 will run every 2 minutes, but H/1 will run every hour.  
> **username_0**: @IanW That's true, but doing * * * * *, runs every minute. That bug is unrelated.  
> **username_2**: OK, so you can't have two lines (with parameters) that run at the same time as it only takes the first one. You can't use H/1 as there no random interval in minute increments. Tje leaves you stuck. So, make 2 jobs, with  * * * * *, and a hard-coded env.  
> **username_0**: @IanW Not sure I understand. Can you explain?  
> **username_0**: @IanW That's very close to the workaround we're currently using. :) I'm looking for a more elegant solution, and maybe an explanation of why this behavior occurs.  
> **username_2**: If you want an explanation, the best I can say is there has been an Open issue for 5 years where 2 Cloudbees (Jenkins sponsor) employees, one of whom is the senior maintainer and the other has been supporting Jenkins since 2008 can't come to an agreement on if it's wrong or whether to fix. Go with your workaround or contribute to the issue. Good luck.  
> **username_0**: @IanW Link to it in your answer and I'll accept it. Thanks!  
> **username_2**: Had added but link needed login. Fixed up.  
> **username_3**: I think you're "doing it wrong" scheduling a job to run every minute is quite a burden on all but an unladen Jenkins. Why not run the job once every 30 minutes, but alter the job to process Cluster1, then Cluster2 then sleep for a minute... and repeat.  

---

## 1 answers

### Answer by username_2 on 2020-06-25. Score: 2 | Accepted answer

I believe your issue is the use of * * * * *.
The parameterized-scheduler-plugin example has two different times specified.
#lets run against the integration environment at 15 past the hour
15 * * * * % env=int
#run QA too
30 * * * % env=qa

So one job runs @15 and one @30.
Yours specify the same time, so only the first is executed.
You could try the random time parameter "H" or fix some different interval on each.
Or, it does say "Leave a space. Put in a %. Then add the name=value pairs". So maybe it's cronexp space percent space name=value ?
OR you could just copy the job job and schedule two separate jobs w/fixed parameter.
But Jenkins does sound like the wrong tool for this.
The above will address why only the 1st line was executed.
NOTE :There is a known issue attemptimg to to every minute, see JENKINS-22129 H/2 will run every 2 minutes, but H/1 will run every hour.


---

