View Full Version : Another ignorant question ffrom me
Martin
Sun 23rd Apr '00, 4:47am
Can a cron job be set up in mySQL to automatically prune topics that are aged by say 60 days?
This would be handy as hell to have :)
John
Sun 23rd Apr '00, 5:41am
I would recommend that you do something like this:
<?php
require("global.php");
$daysdelete=60;
$threads=$DB_site->query("SELECT threadid FROM thread WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(thread.lastpost)) >= ($daysdelete*86400)");
while ($thread=$DB_site->fetch_array($threads)) {
$DB_site->query("DELETE FROM post WHERE threadid=$thread[threadid]");
}
$DB_site->query("DELETE FROM thread WHERE(UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(thread.lastpost)) >= ($daysdelete*86400)");
?>
Upload this into your main vBulletin directory then add this line to your crontab:
0 0 * * * lynx http://www.yourhost.com/forums/prune.php -source > /dev/null
That will do the prune daily.
John
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.