Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for smaller time units, like in Systemd timer or Monit #92

Open
maxadamo opened this issue Dec 17, 2023 · 2 comments
Open

Comments

@maxadamo
Copy link

  • Yet Another Cron version: 0.19.0
  • Python version: 3.12
  • Operating System: containers, ubuntu, centos, Mac

Description

Monit has the ability to schedule jobs per seconds, and now with Systemd timer, it's possible to set a lower accuracy for a job and then schedule a job to run every x seconds or microseconds.

I don't know if microseconds is doable with an interpreted language, but I think that providing an option to run a jobs every x second would be nice and it would be a remarkable improvement to Vixie Cron.

@s-light
Copy link

s-light commented Jun 25, 2024

as i just found out
https://stackoverflow.com/a/43066502/574981

cron only has a resolution of 1 minute (there are other tools I think that may have finer resolutions but they are not standard on unix).

i just switched from supercronic to yacron as i like the yaml syntax very much..
and supercronic just supports it..

parse-crontab supports seconds.

as fare as i can tell it would be needed to be added to

maybe that is already all?!

if so i think i can write a pullrequest for this ;-)

@gjcarneiro
Copy link
Owner

May be a bit more tricky than that. The yacron main loop is a bit more lax:

  1. Test each job crontab, does it match the current minute? If so, start it
  2. Calculate how many seconds do we need to sleep until the start of the next minute
  3. Sleep those seconds
  4. Go back to step 1.

To support second precision, yacron would need to:

  1. wake up every second, instead of every minute
  2. the part "test each job crontab, does it match the current minute" would need to be tweaked:
    1. some cron jobs are specified with only minute precision, they should not "match" every second in one minute interval, otherwise they would be started 60 times per minute, we don't want that
    2. only the subset of the jobs that actually specify sub-minute precision should be allowed to test for a match multiple times per minute.

Personally I don't find it useful, but YMMV, and I wouldn't mind reviewing some code to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants