Web Hosting Talk







View Full Version : Cron jobs - how fast can they go?


mikey1090
04-20-2006, 07:34 AM
I have been running a file each 10 seconds on my website with a unix wget command.

I thought cronjobs only ran at 1 minute speeds.

What speeds do they run at?

Can i make it run at 10 seconds?



mike

linksys
04-20-2006, 11:59 AM
Cron jobs cannot be less than 1 minute. For <1 minute tasks, I think you can write a shell script with "sleep" and put that into rc.

mikey1090
04-20-2006, 12:01 PM
i used to use a shell script - wget

now i dont have shell access

Premier
04-20-2006, 12:29 PM
Other option is to have a cron job to run the script every minute and have the script loop to do it's job 6 times with a 10 second sleep between loops.

mikey1090
04-20-2006, 12:31 PM
ok im interested.....

how can i make a script loop itself when its not being ran in an internet browser

Premier
04-20-2006, 12:41 PM
You have to edit the script.

Example:

simple script
#!/usr/bin/perl
system ("wget www.domain.com");
exit;
would wget domain.com once.

Run it every minute to wget every minute.

repeating script
#!/usr/bin/perl
for ($c=0;$c<6;$c++) {
system ("wget www.domain.com");
sleep(10);
}
exit;
would wget domain.com 6 times, waiting 10 seconds between each.

Run that every minute and you wget every 10 seconds.

orbitz
04-20-2006, 12:42 PM
you make whatever inside the script loop itself - using a while or for loop
$x = 0;
while ($x < 7)
{
// execute me
// your code.
sleep(10);
$x++;
}

ps: for php

Slidey
04-20-2006, 03:40 PM
or just while()

if it needs to be run every 10 seconds regardless, why bother with the cron ;)

orbitz
04-20-2006, 10:00 PM
or just while()

if it needs to be run every 10 seconds regardless, why bother with the cron ;)

without cron job, who's going to execute the script? ;) you can't rely on user alone!

Mini
04-20-2006, 10:12 PM
I've disabled wget and curl to be run by anyone except root. I guess it's for maximum security.

Mini

Slidey
04-21-2006, 04:26 AM
I've disabled wget and curl to be run by anyone except root. I guess it's for maximum security.

Mini

what about ftp/ncftp, or telnet, or allowing people to run their own binaries?

mikey1090
06-10-2006, 12:21 PM
ok, i tried to use the perl method, but was getting internal server error message

when i tried the php method, it was giving me fatal errors, due to calling functions twice