|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Aug 2002
Posts: 1,844
|
i want to execute a script once per day randomly in a 6 hour period e.g. execute a script between 5am and 11am every day. obviously if i'm using a cronjob it's got to be a regular time every day, anyone got a suggestion of how i can execute it randomly?
thanks in advance |
|
|
|
|
|
#2 |
|
Confirmed User
Join Date: Jan 2006
Location: Canuck land!
Posts: 921
|
My idea of doing this would be to run the cronjob multiple time over the 6 hour span and have a random variable inside the script to make it execute or not. You will also need a value stored somewhere to see if you've already executed the script within the last 6 hours.
Good luck!
__________________
40$/Page PSD->XHTML/CSS Transformations |
|
|
|
|
|
#3 | |
|
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
Quote:
Generate a random number between 1-10, then if the random number is < or = a variable then execute the script. Otherwise exit with no action taken. If you set the variable to 2 for instance your script would have a 20% chance of executing.
__________________
I like pie. |
|
|
|
|
|
|
#4 |
|
Confirmed User
Industry Role:
Join Date: Sep 2006
Location: Netherlands
Posts: 217
|
Actually, that still leaves the chance that your script will never, ever execute.
Try just cronning your script once and having your script sleep for a randomized number of seconds. That way, it will run, you just won't be certain when (By the way, shells by default don't have a random number generator as far as I know. You might have to find yourself a random number "program" for that)
__________________
Dido ADAMO Advertising - Your ULTIMATE traffic partner! If you need traffic or have traffic, we'd love to help you make the best out of it! ICQ:24209500 - Skype:diederikvanschaik |
|
|
|
|
|
#5 |
|
Confirmed User
Industry Role:
Join Date: Sep 2006
Location: Netherlands
Posts: 217
|
Oh, actually. It seems that bash has something of a $RANDOM enviroment variable which is .. probably pseudo-random enough for what you want.
__________________
Dido ADAMO Advertising - Your ULTIMATE traffic partner! If you need traffic or have traffic, we'd love to help you make the best out of it! ICQ:24209500 - Skype:diederikvanschaik |
|
|
|
|
|
#6 | |
|
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
Quote:
Generate a random number between 1-6. Store that along with the date in a flat file. When the script runs, have it choose a number between 1-6. If that = the random number then execute the script. You'd have to keep track of the numbers already picked for the day as well as increment the date after the script has already run for the day. Make sure the script doesn't execute again if the date in the text file == today.
__________________
I like pie. |
|
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: Aug 2002
Posts: 1,844
|
thanks guys for all the responses, there's some good sugestions there, i'll go away and have a play with it and see if i can come up with something using your suggestions. i'll post back if i come up with something usable. too be honest i assumed there would already be a utility or something that did this already.
thanks again |
|
|
|
|
|
#8 | |
|
♥♥♥ Likes Hugs ♥♥♥
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
|
Quote:
__________________
I like pie. |
|
|
|
|
|
|
#9 | |
|
Confirmed User
Join Date: Aug 2002
Posts: 1,844
|
Quote:
i'm just having a quick search on google and found the php sleep() function (its a php script i'm trying to run). which maybe a solution but has anyone used this before and if so can i use this for a period of hours (2 hours would do)? and would this function be affected by my php.ini settings e.g. max_exectution_time etc? |
|
|
|
|
|
|
#10 | |
|
. . .
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
|
Quote:
why 1-6?
__________________
__________________ Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs Check out the #1 WordPress SEO Plugin: CyberSEO Suite |
|
|
|
|
|
|
#11 |
|
Too lazy to set a custom title
Join Date: Feb 2001
Location: Tube Titans, USA
Posts: 11,929
|
6 hours. You could use 7 and include both end points.
5am 6am 7am 8am 9am 10am 11am
__________________
skype = "adultdatelink" |
|
|
|
|
|
#12 |
|
Confirmed User
Industry Role:
Join Date: May 2008
Location: USA
Posts: 692
|
just make a wrapper in perl or something
|
|
|
|
|
|
#13 |
|
Chafed.
Join Date: May 2002
Location: Face Down in Pussy
Posts: 18,041
|
A simpler approach:
1)Have 1 daily cron job run a script that generates a random time tag for the day and store it in a db or text file 2)have a second cron running once ever 30 minutes or whatever and check to see if it has passed the randomly generated time. If it has, fire off the task and reset the stored time so it only does it once. |
|
|
|
|
|
#14 | |
|
Confirmed User
Join Date: Aug 2002
Posts: 1,844
|
Quote:
|
|
|
|
|
|
|
#15 |
|
Now choke yourself!
Industry Role:
Join Date: Apr 2006
Posts: 12,085
|
Why not just use cron to do a daily 'at'? I fail to see the need for abusing cron for two jobs that cron, and at, would do better.
__________________
|
|
|
|
|
|
#16 |
|
Confirmed User
Join Date: Jan 2006
Location: Gringo in Puerto Rico
Posts: 4,204
|
run the cron job at a set time, but have the code that it runs, php or other hand the randomization. A simple example would be to have it generate a random number between 1 and 10 and if the number if 7 then run execute the rest of the job, if not exit.... then it'll try it again next time the cron job runs. You'd be bound to have it be 7 now and then.
|
|
|
|
|
|
#17 |
|
Confirmed User
Join Date: Aug 2002
Posts: 1,844
|
|
|
|
|