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?
17
u/syzygy78 May 28 '26
Have you looked at "at"? You can specify execution time as an increment from 'now.' I've used it to create a three line pseudo-daemon which did a thing than scheduled itself to run again in x minutes. It's simpler than cron and works well in scripts.
8
u/chock-a-block May 28 '26 edited Aug 30 '26
Argon versed ten light modern pumpkin
This post was anonymized with Redact
3
u/alexkey May 28 '26
For running at intervals - if you are looking for some lightweight headless solutions - nothing really, maybe custom bash or python script that does sleep to make interval between calls. (Basically `for…sleep` loop) that will get you more or less precise intervals if that’s what you are after.
3
u/karafili May 28 '26
Cron?
3
u/1esproc May 28 '26
You're already using supervisord, just keep using that.
autorestart=trueto your program definition.ENV_SLEEP_INTERVAL(for example) and access via%(ENV_SLEEP_INTERVAL)sin yourcommand=config line, so it's easily set in your composeAll your stdout/stderr shit will bubble up to supervisord like you want
2
u/vogelke May 28 '26
You could approach this by using a dated directory tree that gets cleared and recreated at boot, like /tmp. I have /var/run set up the same way because I don't need old pid files hanging around:
Create the top-level directory at boot time:
Then create a directory for your userid to keep people from stomping on each other's jobs:
Results:
Let's say you want to run something every 25 minutes. For demo purposes, write a message to syslog. At boot, it writes:
After that, every 25 minutes you want it to write:
The script being run doesn't have to be long. Call it "svc.sh":
You could also just move the script to its next timeslot if you're not planning on modifying it on the fly.
If the reboot time is 28 May 2026 03:50:00, root copies svc.sh to /var/run/recurring/kwhali/2026/0528/0350 and executes it as you immediately.
When it's done, a script called /var/run/recurring/kwhali/2026/0528/0415 exists with a modified syslog message.
The main driver for this process is something you run from cron once every minute. If /var/run/recurring/kwhali/YYYY/MMDD/HHMM exists and is executable, run it.
It's a bit of rigamarole, but if you have GNU date it should work for just about any sensible date interval. I use something like this in my home directory to show reminder popups in my XTerm at specific times.
3
u/imbev May 28 '26
1
u/toakao May 28 '26
You need to run a scheduler sidecar container with the app or run a standalone scheduler container like chadburn. But using chadburn means giving access to docker’s socket so you’re trusting the app developers with root on the docker host.
https://github.com/PremoWeb/chadburn
Depending on your pain tolerance, running KinD or K3S would give you a proper Cronjob type object.
1
u/perryurban May 28 '26
Why exactly don't systemd timers meet your requirements?
1
u/michaelpaoli May 28 '26
Well, if you want much more stand-alone, you can do self-rescheduling at jobs.
1
u/dorancemc May 28 '26
I'm moving my scheduled tasks from cron to systemd timers. With ansible, it is easy to create them.
1
u/abotelho-cbn May 28 '26
Can you be more specific? Are you trying to run at application or script that finds itself in a container?
1
u/symcbean May 28 '26
You find it difficult to do this with cron?
Or do you have very specific timing requirements?
1
u/ritonlajoie May 28 '26
I read everything I am not sure why but my take on this if you are allergic to at, cron or other suggestions, make you own in python and call it a day
1
u/Blank-Inspection13 May 31 '26
snooze
2
u/[deleted] May 28 '26
[removed] — view removed comment