Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-23-2007, 06:19 PM   #1
Senior Member
Registered: Feb 2005
Location: San Antonio, Texas
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495

Rep: Reputation: 85
running cron jobs at random times

How is it possible to run cron jobs at random times?
Old 11-23-2007, 06:32 PM   #2
harry edwards
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
I do not think it's possible; although, you could run a script every so many minutes and code the random element into the script i.e.


# Grab a random value between 0-32767.
if[ $value -lt 240 ]; then
<executed command>

This gives a 240 in 32767 chance of execution.
Old 11-15-2017, 12:58 PM   #3
Registered: Apr 2011
Distribution: slackware64-current
Posts: 421

Rep: Reputation: 43
Originally Posted by fakie_flip View Post
How is it possible to run cron jobs at random times?
To run everyday at a random time:
0 0 * * * sleep `echo $RANDOM/32767*86400 | bc -l`; <command_to_execute>
86400 is the number of seconds in a day, and 32767 is the maximum value $RANDOM can be.
Old 11-15-2017, 01:54 PM   #4
Senior Member
Registered: Mar 2010
Distribution: Slackware
Posts: 1,553

Rep: Reputation: 247Reputation: 247Reputation: 247
You may want to use at instead. You can schedule an at job by echoing a string into it; ctrl-d is the end. echo -e allows sending special characters.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron jobs not running henrybg Linux - Enterprise 10 01-28-2013 11:23 AM
cron is running but jobs aren't kalahari875 Mandriva 4 03-15-2006 04:47 PM
One user's cron jobs not running dcroxton Linux - Software 5 03-06-2006 04:33 PM
shutdown only if no cron jobs are running Red Squirrel Linux - Software 4 08-31-2005 02:00 PM
cron jobs not running scarr3d Linux - Software 7 05-25-2004 05:21 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration