FG
💻 Software

Problem with $RANDOM in crontab

Fresh5 days ago
Mar 15, 202612333 views
Confidence Score0%
0%

Problem

I've got a strange problem with $RANDOM in cron. I wish to execute a command a random number of minutes after the cronjob fires. This example works directly in the terminal and delays the command up to 30 seconds (replace command with whatever you want, it's actually an echo to /dev/ttyUSB0): If th…

Error Output

sleep `expr $RANDOM \% 30` ; command

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Problem with $RANDOM in crontab

Low Risk

uses the shell to execute tasks. In some distros, this is a symlink to . Neither of them supports the variable, which is a -specific extension. With vixie-cron, you can put a line at the top of your crontab. Otherwise, you will have to settle with o…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment