question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cron x/y pattern not working as espected

See original GitHub issue

Hi,

I noticed that pattern x/y, as every y starting from x is not wotking

According to crontab.guru this pattern should produce:

“At every 2nd minute from 0 through 59.”

But in the attached code i’ve noticed a different behavior (applied to seconds for brevity). It triggers just at the very start of every minute insted of every 2 seconds starting from second 0

var event = schedule.scheduleJob("0/2 * * * * *", function() { var dt = dateTime.create(); console.log("Inserting new data: " + dt.format('Y-m-d H:M:S')); });

Output:

Inserting new data: 2017-09-13 16:35:00 Inserting new data: 2017-09-13 16:36:00 Inserting new data: 2017-09-13 16:37:00 Inserting new data: 2017-09-13 16:38:00

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
santigimenocommented, Nov 18, 2017

@fabiomor I’ve been looking into this and TBH after reading the crontab manual I’m not sure that format is correct:

Step values can be used in conjunction with ranges. Following a range with “/<number>” specifies skips of the number’s value through the range. For example, “0-23/2” can be used in the ‘hours’ field to specify command execution for every other hour (the alternative in the V7 standard is “0,:2,:4,:6,:8,:10,:12,:14,:16,:18,:20,:22”). Step values are also permitted after an asterisk, so if specifying a job to be run every two hours, you can use “*/2”.

I’m not completely sure that using a value with step values is a valid crontab expression. It seems that only ranges and * are valid. /cc @harrisiirak what do you think?

Anyway, for your use case you could always use 0-59/2 * * * * * and it should work.

0reactions
santigimenocommented, Nov 20, 2017

Closing then. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cron job not working as expected configured with Quartz ...
First scheduler which runs every 5 minute forever works well without any problem. Second scheduler expression ( 0 30/5 9-14 ? * MON,TUE,WED,THU, ......
Read more >
How To Use Cron to Automate Tasks on Ubuntu 18.04
Cron is a time-based job scheduling daemon found in Unix-like operating systems, including Linux distributions. This guide provides an ...
Read more >
Cron job troubleshooting guide - Cronitor
This guide will walk you through locating cron jobs on your server, validating their schedules, and debugging common problems.
Read more >
Why is my crontab not working, and how can I troubleshoot it?
The vast majority of "my cron script doesn't work" problems are caused by this restrictive path. If your command is in a different...
Read more >
Kubernetes CronJobs at Scale Part 1 by Kevin Yang
In our old environment, the machine running that cron is sitting idle 99.85% of the time. With Kubernetes CronJob, compute resources (CPU, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found