r/linuxadmin • u/kwhali • May 28 '26
Does anyone know of a standalone program with functionality like systemd-timers?
This is something I'd find handy for containers that cannot as easily leverage systemd-timers (at least anyone using an image via Docker AFAIK), and I suppose distros that insist on not using systemd.
cron (and variants) is alright, but sometimes I find myself needing to run a program at a recurring interval and would prefer to have the option of invoking the command as a service is started, and then repeating calls after N delay of time, rather than a variable amount of time until aligned with a cron expression schedule (at the hour or incremental interval, but that intervals become inconsistent if they don't cleanly segment the unit ceiling).
For context, I've also asked this same question over at r/docker.
I'd like to pair it with a service manager like supervisord for any services that lack a daemon/poll feature but should be run regularly at an interval. I know cron / supercronic effectively support this and can be considered "good enough" :\
Surely something like this exists out there already? Or would I need to DIY my own command wrapper for this?
View all comments
Show parent comment
1
u/kwhali May 28 '26
Yeah I am already roughly doing that but when you add the sleep it can complicate the management?
If you sleep before the command, how would you be able to stop the service without waiting on sleep to complete since signals aren't forwarded?
If sleeping after (which I want anyway) I'm pretty sure the concerns with sleep are avoided with
execlike this:That will bubble up a non-zero exit status from the earlier command with the
&&short-circuit, but I don't know about forwarding a signal to my-command if it's presently processing at the time?In this case it's not a big deal but if it did take quite a while it wouldn't receive the signal unless you add a trap prior? The
execotherwise would ensure it was fine with the sleep and would exit that process immediately.I think with the above stdout/stderr from
my-commandwould work fine too, bit tired atm 😅I have mentioned the above somewhere before in an earlier comment, it's the closest solution that fits, assuming a process supervisor and a shell are present in the image.