A script that runs automatically...say...once a day?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

A script that runs automatically...say...once a day?

Post by paladaxar »

Okie dokie. I am building a website where people list things for a set amount of time (ex. one week, 3 days, etc.) Once the time of thier listing runs out, it is useless to keep thier entry in the database. Is there any way that I can write a PHP script that automatically runs (maybe once a day) and cleans up the database by removing outdated entries?

Thank you in advance...You guys are awesome!
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Cron job?
paladaxar
Forum Commoner
Posts: 85
Joined: Fri Jun 18, 2004 11:50 pm

Post by paladaxar »

Newbie here. Explain "Cron Job"
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Its a service on linux/unix machines that executes certain commands/programs at certain points in time. "man cron" if you have a linux machine, if you dont then take a look at the schedual thing in windows.
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

If your host uses cPanel login and there's an option called 'Cron jobs' Set one up.
LiquidPro
Forum Commoner
Posts: 37
Joined: Wed Aug 04, 2004 6:33 pm
Location: Akron, OH

Post by LiquidPro »

Another thing you could do is before your site does any work, you could simply check the database for their times, if any of the times are up... it removes it from the database. You'd need to store the initial time that the service started in the database, that way you can check it against the current time. It's basically making a script cron job, which doesn't need your linux service to do it.

If you need me to elaborate more... let me know.
Post Reply