> > 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)?
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?

> And the former achieves a resolution of seconds instead of minutes.

Why do you need that?

Are you prepared for the situation when the script runs on the 59th second
of one minute, and on the 01th second of the next minute?

> > and how exactly does it not work?

> Given these two crontab lines the second never produces output:
> * * * * * echo "$(date)">>/home/username/test-trigger-a.log
> * * * * * time $((RANDOM % 60));echo 
> "$(date)">>/home/username/test-trigger-b.log

But surely it produces an error message,
as "time NUMBER" is not valid syntax.

> But you are correct: It is not RANDOM that is the problem,
> but apparently the $((...)) calculation does not work. E.g. this works:
> * * * * * echo $RANDOM>>/home/username/test-trigger-c.log
> This doesn’t:
> * * * * * echo $((RANDOM % 60))>>/home/username/test-trigger-d.log

Read about the ‘%’ char in crontab(5).

        Jan

Reply via email to