Page 1 of 1
Seeking alternatives for Crone Jobs
Posted: Tue Jul 26, 2005 12:37 am
by jeephp
Hi
I have a site in PHP on IIS 6 and need some sort of scheduling
functionality for sending emails via php scripts, running scripts on
database etc.
I worked a bit with Crone Jobs for this however I was wondering if there
is something better then that. Site is developed in PHP / MySQL and
running on Windows 2003 with IIS 6.
Any help!
Posted: Tue Jul 26, 2005 12:45 am
by josh
You could use a system of timestamps, and when a page view is triggered check the time() and see if it's time to do a job. I've done this with a few sites, one for instance is a site where it takes 10-20 seconds to generate the "top 10" list, seeing as the list doesn't need to be generated every page view, I simply check if its been updated in the last 10 minutes, if not I'll serve up the old list, and at then run a shell script (written in php) to regenerate the top 10 list. This is "better" then cron in my opinion (for the situation) because during peak hours when theres a lot of traffic it gets updated every 10 minutes, but when I'm getting one hit per hour there's no need to update it every 10 minutes, it's just wasted cpu. You also need to code measures to make sure the update doesn't get done 5 times at once if 5 people load the page at the same time.
Posted: Tue Jul 26, 2005 1:14 am
by John Cartwright
I know this probably isn't what you want to hear, but what is wrong with crons?
Posted: Tue Jul 26, 2005 3:41 am
by onion2k
Is a crone job like a cron job, but with a broomstick and a pointy hat?
As you're on Windows, you could just Task Scheduler. It's not as good as Cron though.
Posted: Tue Jul 26, 2005 7:31 am
by theda
I'm sure you can download thousands of automating programs off the net to do what you're asking... If they're as good as cron, is yet to be seen...
Posted: Tue Jul 26, 2005 11:47 am
by Roja
onion2k wrote:As you're on Windows, you could just Task Scheduler. It's not as good as Cron though.
The best of both worlds:
ICron - an implementation of Cron as a Windows service
Posted: Tue Jul 26, 2005 1:24 pm
by josh
Jcart wrote:I know this probably isn't what you want to hear, but what is wrong with crons?
Sometimes cron just isn't available:
jeephp wrote:running on Windows 2003
I didn't use cron on my site because there's no point updating the "top 10 list" every 10 minutes if no one is going to the site for 4 hours. While I could have had the cron run a script that checks if some one has been to the site < 10 minutes ago and if not exits, I decided not to.
Also, correct me if I'm wrong (I know nothing about cron) but I beleive cron can't handle 'complex' instructions, as in cron can't run every 7 minutes for example, you have to set pre-defined times for it to run, so if your interval isn't divisible by 60 you're screwed.
Posted: Tue Jul 26, 2005 1:32 pm
by hawleyjr
Yeah you can
Code: Select all
*/7 * * * * GET http://www.example.com/test.php >/dev/null
Edit:
Posted: Tue Jul 26, 2005 2:03 pm
by josh
hawleyjr wrote:Yeah you can
I learn summin new every day
Posted: Tue Jul 26, 2005 4:29 pm
by Roja
jshpro2 wrote:
Also, correct me if I'm wrong (I know nothing about cron) but I beleive cron can't handle 'complex' instructions, as in cron can't run every 7 minutes for example, you have to set pre-defined times for it to run, so if your interval isn't divisible by 60 you're screwed.
Honestly, I've only had *ONE* major complaint about cron, and its really more about php..
It cant say "Only run if load is under X%". If they added that, I'd want to marry Cron.
Of course, if php.ini could have a cpu usage throttle amount in php.ini the world would be a much better place.
Posted: Tue Jul 26, 2005 4:48 pm
by timvw
But instead of starting the script immediately, you could write a little wrapper in bash (or something alike) to test the load?
Code: Select all
#!/bin/bash
load=`top -n 1 | grep Cpu | awk '{print $8}'`
if ї $load < '50.0%' ] then;
/usr/bin/php /home/user/test.php
fi
Posted: Tue Jul 26, 2005 5:18 pm
by Roja
timvw wrote:But instead of starting the script immediately, you could write a little wrapper in bash (or something alike) to test the load?
Thats pretty much what I did, but thats just working outside the limitations.. would be nice to have it built in.