PDA

View Full Version : Update content every 24 hours


crighton
12-03-02, 14:20
Hi,

I'm looking for some basic guidance on the best method to automate the following task:

1) Pull some basic data / image from a database.
2) 24 hours later go back to database and redo the above to replace current content with new content.

I've looked around and can't find scripts close enough to the above for me to work out the best way to approach it. I know it involves two basic concepts:

1) Some sort of date / time comparison to control the 24hr update sequence (no date or timestamp is included in the Db table to be used).
2) Some way to randomly pick replacement content from the Db by id number.

Any suggestions or script samples are welcome. Not looking for any finished scripting here just pointers / samples on how best to approach it.

Many thanks,

Gary Crighton

Bruce A. Baasch
12-03-02, 16:00
Hi Gary,

I would break your problem into three pieces:

"Refresh" application - sequentially reads your "old" database, randomly accesses the "new" database and copies the contents from "new" to "old".

"Maintenance" application - allows you to add or remove a record from the "old" database.

Windows Task Scheduler to execute the "refresh" application during "off-peak" hours.

Good Luck,

bcyde
12-27-02, 12:56
Can you give a little more info? I'd like to help but need more info.

If you're on a *nix system you can just enter a job in your crontab to run at the same time every day to call your PHP script. I'm not sure if this is completely applicable, but if I just wanted to update an image every day, say for something like an image of the day script I'd just have the list of files in a database with a timestamp and in my script check for the specific timestamp you want and have the cron job run every night. If you know just want the latest file you can bypass the whole database thing and have your script simply search the files in a directory and check their file properties for when they were last updated.


Can you go into more specific details about what type of help you need?
Hope this helps,
-b

aZa
01-17-03, 18:15
cronjob is the thing you need if you are using *NIX hosting solution. Simply create some simple script to change link in the HTML file for the current, say 'image of the day' source file, chmod it to 755 and put in cornjobs as a task to cpmplete once per day.

Very easy to implement, nothing guru-like in this task, so don't be afraid to get in this a bit deeper. :D

P.S.: Task-sheduler should do the same thing as well for Windows systems. But I personally never tried it myself, so can't say for sure if it works fine. It should anyway. ;)