»Chapter 11. Scheduling Maintenence tasks

From the LiveJournal user account (or whatever user is running LJ), you need to install some crontabs. These are periodic commands that run and manage your LiveJournal installation.

$ crontab -e

Note

This will bring up either your $EDITOR, or vi. If you want to set your editor explicitly, do:

$ EDITOR=pico crontab -e

Now, enter the following stuff between the dotted lines below. Not all of it is necessary. See the comments below. The LJHOME= line is required. See the section above about how the $LJHOME environment variable is required everywhere. This is another place.

LJHOME=/home/lj
MAILTO=youremail@wherever.com

# Essential:
* */12 * * * /home/lj/bin/ljmaint.pl clean_caches >/dev/null

# Optional, if you want birthday mail, and the random user feature:
# (you can remove parts)
5 1 * * * /home/lj/bin/ljmaint.pl bdaymail build_randomuserset >/dev/null

# If you want statistics:
30 1 * * * /home/lj/bin/ljmaint.pl genstats genstatspics genstats_size >/dev/null
5 2 * * 0 /home/lj/bin/ljmaint.pl genstats_weekly > /dev/null

# Various tasks
15 1 * * * /home/lj/bin/ljmaint.pl joinmail > /dev/null
30 * * * * /home/lj/bin/ljmaint.pl synsuck > /dev/null
5 2 * * 0 /home/lj/bin/ljmaint.pl memeclean > /dev/null

# If you're running a high-load site with $LJ::BUFFER_QUERIES on,
# there's another one to install:
*/5 * * * * /home/lj/bin/qbufferd.pl >/dev/null

If query buffering is off, you can still run that, but it's not needed. Packagers should make their packages install it, since it doesn't hurt if it's running and not used. It'll die off right away if it realizes it's not needed. Otherwise it'll start up in the background and run every 10 seconds or so. Future startups by cron will only make sure it hasn't died (like if the database dies).