LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

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
Member
 
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.

#!/bin/sh

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

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

Rep: Reputation: 37
Quote:
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:
Code:
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
RandomTroll
Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 602

Rep: Reputation: 72
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.
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:55 AM.

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