PDA

View Full Version : Cron Job to Prune Thread


tafreeh
03-25-2012, 07:32 PM
Hello,
How can I setup a Cron Job to permanently delete soft deleted thread && thread has been soft deleted for more than 7 days.

OR

Permanent Delete all threads from a forum that are only 7 days old. In this case Delete only X amount of threads per day.

Please guide.
Thanks

kh99
03-26-2012, 08:41 PM
If you write a script to do what you described, you can put it in includes/cron and then create a new scheduled task to use it. You can look at the other scripts in that folder to see how they work.

I'm not sure if that's a lot of help - as for the thread pruning, you can find that code in an existing script and copy it. I think admincp/thread.php has code for when you do it from the admincp.

tafreeh
03-26-2012, 11:45 PM
okay, I will look into it. But if someone else be more helpful that would be great !!

Thanks a lot kh99

Pandemikk
03-27-2012, 04:26 AM
There's no easy way to tell, natively, when a thread has been soft deleted. However, a work-around to this would be to delete threads where the last post is older than 7 days ago and the thread is soft deleted. The reasoning behind this is that once a thread has been soft deleted it won't be posted in anymore.


define('ONE_WEEK', 604800);

$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "thread WHERE lastpost <= " . (TIMENOW - ONE_WEEK) . " AND visible = 0");


This will delete all soft deleted threads that haven't had a post in the past 7 days. Untested- should work fine.