PDA

View Full Version : Administrative and Maintenance Tools - Execute Scheduled Tasks Via Crontab


Jafo232
12-05-2007, 10:00 PM
This product will run your scheduled tasks via crontab rather than the current method where Vbulletin uses an image to execute tasks. This can slow down a users experience especially with long running tasks. It also stops all of those cron.php entries in your webserver log.

This product is really only useful for those on *nix (Linux/Unix/Etc) servers. Will not work on Windows based servers.

You should have a rudimentary understanding of crontab (http://en.wikipedia.org/wiki/Cron) before installing this hack.

For those wondering how this differs from this hack (https://vborg.vbsupport.ru/showthread.php?t=122647), well, first of all, it works for 3.6.8, but more importantly it actually replaces the method Vbulletin uses to execute scheduled tasks, whereas the other hack only helps it out.

https://vborg.vbsupport.ru/Please Click Install!https://vborg.vbsupport.ru/ (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=164477)

Brought To You By WorldWideCreations.com (http://www.worldwidecreations.com).

mobilescafe.com
12-06-2007, 03:51 AM
Thanx for this.

yahoooh
12-06-2007, 04:12 AM
Thanx

Jafo232
12-06-2007, 03:14 PM
Your Welcome. :)

plothook
12-06-2007, 05:02 PM
*Marked as Installed*
Nifty little utility. Thanks

Jafo232
12-07-2007, 01:30 AM
Your welcome.. Let me know if you have any issues with it.

Benj
12-07-2007, 05:41 AM
very useful cheers

Jafo232
12-07-2007, 02:40 PM
very useful cheers

If you find it useful, by all means, click install. :)

GoodKarmaKid
03-17-2008, 04:37 PM
does this work with vb 3.76beta ?

I'd like to install this and get rid of the dumb vbulletin way of running the tasks.


Thanks,
jason

GoodKarmaKid
03-18-2008, 02:06 AM
I'm not much of a programmer or a coder, but I can follow directions :D

I've uploaded this to vbulletin 3.76beta and it appears to work just fine, I will continue to keep my eye on it, but as far as I can tell it is working as intended.

Thanks for the add on

Jason

Jafo232
03-18-2008, 01:38 PM
Don't see why it wouldn't, but I for one will not modify any plugin for a beta. When it is released, then I consider it.

GoodKarmaKid
03-28-2008, 02:14 AM
Don't see why it wouldn't, but I for one will not modify any plugin for a beta. When it is released, then I consider it.

Do you consider RC1 (release candidate 1) a release ? :).


I like the idea of using this instead of vbulletins built in cron tasks.


Thanks,
Jason

Jafo232
03-28-2008, 01:18 PM
No I don't consider it a release. You are always free to try it yourself. :)

Jafo232
03-30-2008, 03:31 PM
Unless they have seriously changed the way scheduled tasks are done, I don't see how it would not work in the latest beta versions.

|Jordan|
12-15-2008, 05:20 PM
Can this increase server load? My webhost just contacted me saying that cron.php among other scripts were using too much cpu.

Jafo232
12-16-2008, 01:44 PM
Can this increase server load? My webhost just contacted me saying that cron.php among other scripts were using too much cpu.

Not this mod. This mod just calls cron.php just like it normally would except on an exact schedule. It could be you have a scheduled task that is using a lot of CPU though.

plothook
01-15-2009, 04:53 PM
I have been using this mod for quite some time (clicked install over a year ago) now, and always lived with vBulletin cron tasks running one at a time when the linux cron ran once a minute.

But last week I got ambitious and dug into the bash shell to write this script that runs all the tasks scheduled for any any particular minute, instead of allowing them to sit in 'backlog' until the next minute.

#!/bin/bash

#----- environment setup -----#
# Absolute path to vBulletin root (where cron.php is located)
ct_pathtoforum='/home/user/public_html/forum/'
# Max tasks to run on one pass
ct_max=10

#----- database setup -----#
ct_dbhost='localhost' # your MySQL Server
ct_dbport='3306' # your MySQL Port
ct_dbname='forum' # your vBulletin database
ct_dbuser='username' # user with READ access
ct_dbpass='password' # password for the above user
ct_dbprefix='' # database prefix, if required

#----- query execution ----#
ct_date=`date "+%s"` # current unix time
ct_connect="--protocol=socket -h$ct_dbhost -P$ct_dbport -u$ct_dbuser -p$ct_dbpass -D$ct_dbname"
ct_query="SELECT COUNT(*) FROM ${ct_dbprefix}cron WHERE active=1 AND nextrun < $ct_date;"
# -A, No automatic rehashing, gives quicker start.
# -B, Batch mode.
# -N, Don't write column names.
# -n, Flush buffer.
# -q, Don't cache.
# -r, Write raw fields.
# -e, Execute command and quit.
ct_repeat=`mysql $ct_connect -A -B -N -n -q -r -e"$ct_query"`

#----- cron execution ----#
ct_pathtophp=`which php` # path to PHP
cd $ct_pathtoforum
if [ "$ct_repeat" -gt "$ct_max" ]; then ct_repeat=$ct_max; fi
for ((i=0; ct_repeat>i; i++)); do
#echo "$i"
$ct_pathtophp ./cron.php >& /dev/null
sleep 5
done

exit 0

OnyxChase
04-08-2009, 01:17 AM
Why not just use:

/usr/bin/php /home/username/public_html/forum/cron.php >& /dev/null

??? :)

Jafo232
04-08-2009, 05:45 AM
Because then you are still displaying the cron.php image..

OnyxChase
04-08-2009, 06:37 AM
Ah, I understand what you are saying. But I still think it is better to call the /usr/bin/php directly rather than using a .SH script that does the exact same thing.

But of course, the product XML would have to be loaded to remove the $cronimage from displaying.

plothook
06-19-2009, 07:46 PM
You need the shell script to change the working directory to where vBulletin lives.
If you call /usr/bin/php directly from cron, your working directory will be $HOME for the account running cron and cron.php won't find any of the includes it needs.

Darkimmortal
10-27-2009, 02:25 AM
Thanks, this is a very useful mod :)

It also works on Windows for those of you that have cronw (http://cronw.sourceforge.net/) installed.

lord_of_chaos
02-18-2010, 05:26 PM
Does still work with vB 4.

Im Happy! :)

cbj
04-26-2010, 08:28 AM
Humm.. Why not adding this to crontab..?

(Needs wget, fetch or similar).

* * * * * /path/to/wget -O /dev/null "http://myforum.com/cron.php" >> /dev/null 2>&1

The image is still fetched, but not stored or displayed - as wget, when invoked with the "-O" option, outputs the data to /dev/null.

It seems to work fine here. :)

btlewand
04-13-2011, 12:25 PM
Any directions on how to use this add-on? Added the .xml file into vBulletin and scheduled the CRON script in my cPanel but nothing is happening.

ru55ian
06-26-2012, 11:31 PM
anyone tested this with 4.2?

Darkside2012
01-15-2013, 01:39 PM
anyone tested this with 4.2?

yes..... works fine for me