Improving task automation

jennifer_

New Member
Joined
Jun 25, 2024
Messages
3
Reaction score
3
Credits
30
I am trying set up some automatic tasks in ubuntu.
I followed a tutorial that helped me set up some cron jobs for the periodic tasks.
I was curious if there are any tools in cron jobs that would let me select a random time within a time period to do a task?
The tutorial didn't have anything similar.
 


It's likely that the cron jobs in a systemd installation are actually run by systemd rather than independently by cron. That can be checked with:
Code:
systemctl status cron.service

In that respect the framework provided by systemd which replaces cron is systemd timers which is far more flexible and capable than cron processes are by themselves, and which has the capabilities of random processing that you mentioned.

Perhaps check out the options:
RandomizedDelaySec=
FixedRandomDelay=
in the systemd.timer manpage.

Some useful examples using systemd timers are here:
 
Last edited:
If using regular cron, I don't think there's a way to -schedule- the job for random time within a period but you could, for instance, schedule a job for "every ten minutes" and then have the job itself sleep for zero to 9 minutes before doing anything else. Feels kind of kludgy, but could be made to work.
 

Staff online


Latest posts

Top