PDA

View Full Version : Cron job: Prune forums


jamoss
02-11-2003, 10:00 PM
If you get the kind of traffic like we do-- average 2,000 messages post per day-- you need to do a lot of pruning.

Here's a hack that will automatically run a script daily (or weekly) that will select forums to prune, choose how old the pruned threads must be, deletes the threads, then updates the thread and post counts (all configurable). Author assumes that you have access to your server's filesystem and can edit your crontab file, located in /etc

Steps:

1. Edit your crontab file (in /etc) and add one of these lines:

If you want to run it DAILY at 12:01am
01 00 * * * root /usr/local/bin/php /fullpath/to/yourboard/admin/cron_prune.php >dev/null

If you want to run it WEEKLY, every SUNDAY at 12:01am
01 00 * * 0 root /usr/local/bin/php /fullpath/to/yourboard/admin/cron_prune.php >dev/null

(replace /fullpath/to/yourboard/admin/ with the actual server path to your vB admin directory)

2. Put the attached file (cron_prune.php) in your board's admin directory.

3. Edit the cron_prune.php file and enter your own settings at the top of the file.

If you have any questions, post them here (I'll subscribe to this thread) or email me at jennifer@babynames.com

Let me know if it works for ya! It works for us!
Jenn

PSI|Dr-X
02-12-2003, 02:51 PM
I will try cuz i really need it :)

Dean C
02-12-2003, 03:22 PM
Wow sounds nice for big boards. I'll put a few of my friends in touch about this :)

- miSt

Xenon
02-12-2003, 04:26 PM
hmm, in don't like pruning old msgs....

ok, move em into an archive is ok :)
but good hack if you have to prune :)

Dean C
02-12-2003, 05:42 PM
Xenon - compressing threads is good but a friend of mine has a board with over 60,000 posts. He has to prune each week and even compressed this is not enough ;)

I pointed this to him today so perhaps he'll try it out :D

- miSt

Xenon
02-12-2003, 10:07 PM
well i know some boards with over a million posts, what should they say? ^^

Dean C
02-13-2003, 03:20 PM
Sorry i meant 60,000 members. I'd hate to think how many posts they have ;)

rsuplido
02-23-2003, 06:51 AM
Thanks Jenn. This will be good for our Off-Topic forum.

jamoss
04-04-2003, 01:53 AM
In the attached zip file is an update to CRON_PRUNE.php and the instructions on how to install.

- allows multiple forum pruning with each having its own 'prune all messages older than X days' threshold.

- bypasses login screen in global.php

ryancooper
04-09-2003, 06:11 PM
BEAUTIFULL Just what I need!!! Is there a way to test to see if the cronjob is set up properly?

BTY great site. My wife will love it, she just came home with 2 baby name books!!

jamoss
04-11-2003, 03:47 PM
Thanks, Ryan!

You can run the script manually from the browser to see if it's working for you, but note that you will not receive any output in the browser. When it's done, it will either just stop running with a blank screen or say "No Data".

Jennifer.

ImportPassion
04-13-2003, 09:44 PM
just a note, foe some reason my global.php had this.

if ($bbuserinfo[userid]==0 and $checkpwd) {


instead of this

if ($bbuserinfo[userid]==0 && $checkpwd) {


I have 2.2.9. So if you have trouble finding that line, this may be why.

Derek

ryancooper
04-20-2003, 12:53 PM
04-12-03 at 04:47 AM jamoss said this in Post #11 (https://vborg.vbsupport.ru/showthread.php?postid=380635#post380635)
Thanks, Ryan!

You can run the script manually from the browser to see if it's working for you, but note that you will not receive any output in the browser. When it's done, it will either just stop running with a blank screen or say "No Data".

Jennifer.


Well it works but I get a database error:

Database error in vBulletin Control Panel 2.3.0:

Invalid SQL: DELETE FROM searchindex WHERE wordid IN (0) AND postid=
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

mysql error number: 1064

Date: Sunday 20th of April 2003 08:51:59 AM
Script: http://www.talkdisney.com/forums/forums/admin/cron_prune.php
Referer:

could this be because i emptied my searchindex to save space?

ImportPassion
05-22-2003, 10:06 AM
any idea why I get this when trying to run this on command line

[root@srv1 forums]# php -q /home/virtual/site1/fst/var/www/html/forums/admin/cron_prune.php

Warning: main(./config.php) [http://www.php.net/function.main]: failed to create stream: No such file or directory in /home/virtual/site1/fst/var/www/html/forums/admin/global.php on line 96

yet if I go direct to the admin dir and run the script w/o the whole path but with just the file, it works no prob.

D

jamoss
05-22-2003, 02:00 PM
look in global.php and see what it's trying to do on line 96.

tpearl5
07-04-2003, 05:51 AM
Just what I needed! Thanks! I think there's a lot of people that are looking for something like this but didn't type in the right search terms to find it. Works great in combination with the newsgroup hack for deleting old threads that can take up extra space. :)