Seeking alternatives for Crone Jobs
Moderator: General Moderators
Seeking alternatives for Crone Jobs
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!
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!
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
The best of both worlds:onion2k wrote:As you're on Windows, you could just Task Scheduler. It's not as good as Cron though.
ICron - an implementation of Cron as a Windows service
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:
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.jeephp wrote:running on Windows 2003
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.
Yeah you can
Edit:
Code: Select all
*/7 * * * * GET http://www.example.com/test.php >/dev/nullHonestly, I've only had *ONE* major complaint about cron, and its really more about php..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.
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.
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