Forum Moderators: coopster

Message Too Old, No Replies

How to schedule jobs on a php host?

         

stanza

8:13 am on Sep 30, 2004 (gmt 0)

10+ Year Member



I'm using a php hosting company for my website. It seems most php pages are user-event triggered, so it is difficult to schedule something to run regularly.

For example, user puts something in discussion board, and I need to update my search index to include it. Since building index is pretty IO intensive and takes long time, I hope to do it once a day when traffic is very low or zero so it doesn't impact server performance. I can't really rely on user events to trigger such things. For example, user won't expect his click would trigger a 20 minute delay so I can piggy bag an index-build at the page handler, and there might not even be user clicking my site at the time I desire.

Is scheduling for jobs (or something similar) achievable using regular PHP? (I don't have shell login, etc. for the typical PHP hosting service).

jamie

2:40 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



couldn't you use windows scheduler to launch a browser and load the php script? just a thought, never tried it myself.

timster

3:16 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What sort of search index is this?

Isn't there a way to icrementally add input as it occurs, and then maybe rebuild the index in the wee hours of Saturday night?

mincklerstraat

3:20 pm on Sep 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can write a php script and ask your host to add it to a cron job. Pretty easy if your host has cpanel - there's an interface there for adding cron jobs. Tell your host when / how often it needs to run and where it is, and they can add it. If you're not sure exactly when / how often, have them run it a lot, and program in a time-based conditional as to whether it actually does all the stuff or not. Then you just change the script itself to change the time that it runs from 12:15 to 3:15, or you can make it run twice a day at non-peak times.

a tutorial: [phpfreaks.com...]