Posts tagged haystack

Django: the easiest way to run manage commands in crontab

Sometimes there are some management commands I would like to run from crontab at given time or interval. There are some ways when you import setup_environ from Django but there is much simpler solution.

For example - Haystack search index update. Let’s do it in one hour interval.

user@server:~$ crontab -l
PYTHONPATH=":/home/www/project/django/lib/python2.5/site-packages"
DJANGO_SETTINGS_MODULE=project.settings

# m h  dom mon dow   command
0 * * * * /home/www/project/manage.py update_index

So, all you need is to set PYTHONPATH and DJANGO_SETTINGS_MODULE according to your settings. And the trick is that it can be done in crontab.

Note that this was tested on Debian Linux.

Tuesday, May 25, 2010 — 1 note   ()