fischer+o...@lavielle.com (Mike Fischer), 2025.05.16 (Fri) 17:53 (CEST):
> > Am 16.05.2025 um 17:33 schrieb Jan Stary <h...@stare.cz>:
> >>> How exactly are you using RANDOM in a crontab,
> >> * * * * * time $((RANDOM % 60));/home/username/bin/script.sh
> > That doesn't make any sense: do you mean sleep(1) instead of time(1)?
> Sorry, yes. sleep is correct.
> > Show the actual lines from the actual crontab -l
> >> The (intended) semantics are slightly different from
> >> ~ * * * * /home/username/bin/script.sh
> >> The latter calculates the random value once when the crontab is loaded,
> >> while the former calculates it each time the crontab entry is triggered.
> > Why do you need that?
> a) To get more randomness.
> b) To get seconds resolution instead of minutes.

I found an old crontab(5) entry from the dark ages when we did not have "~":

#5      *       *       *       *       sleep $((RANDOM \% 2048)) && 
/usr/libexec/spamd-setup

Here you see what guenther@ already told you: "%" is special in
crontab(5)s.

Marcus

Reply via email to