Our great sponsors
-
ruby-timeout-interrupt
Discontinued Timeout-lib, which interrupts everything, also systemcalls. It uses libc-alarm.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
There are multiple ways to achieve this. Probably the simplest and most reliable is to rely on cron to run your process every minute. Cron keeps track of time and executes your script each minute. This has the added benefit of avoiding a long running process (which can have its own issues). You can even have your script install itβs own cron job using the Whenever gem.
You might be interested in using timeout-interrupt which uses the alarm syscall which causes the kernel to send the process a SIGALRM signal after the specified amount of seconds.
Monotime's README mentions a pattern for a loop that makes some effort to take into account its own execution time, though it does still drift slightly. I should probably offer a more precise example, like I will here:
Related posts
- The Linux Scheduler: A Decade of Wasted Cores (2016) [pdf]
- Show HN: Windmill β fastest open-source workflow engine β the how
- Croner β Cron for JavaScript and TypeScript
- Scheduling Periodic Jobs with Redis in Rails Microservices Architecture
- kubestellar/kubestellar: KubeStellar - a flexible solution for challenges associated with multi-cluster configuration management for edge multi-cloud and hybrid cloud