tags:

views:

53

answers:

2

i want to have an automatic maintainance of my mysql database.

eg deletes all old threads, users and checks if a user hasnt been active (ive set up that javascript is updating a status column in mysql) for over 60 min, i set the persons status as logged out in mysql. stuff like that.

now how should i do this part. should i write this code in a php file and then fire it up with Firefox and let it be opened all the time.

is this the right method? any other suggestions are welcomed

+3  A: 

Write your maintenance script in PHP and schedule it to run on a regular basis using cron. Don't rely on a desktop browser window.

Asaph
+3  A: 

The PHP interpreter can be called straight from the command line, or in your case, a cron job.

Just be aware that called this way, some of the automatic GLOBAL variables won't be set (there's no REQUEST, SERVER, etc) but you most likely don't need those for your task anyway. Be further aware, though, that when you call a task from a cron job, many of the environment variables you expect to be set up in your command line, aren't. That's because cron shells don't process your login scripts.

dj_segfault