0

I have a custom command in one of my Django apps called test_cron_command that I would like to run using a crontab. I am running this in my development environment which is os x Mavericks in a virtualenv. I read a number of references that demonstrate it can be done with a simple crontab line (example). However I cannot get it to work.

This crontab causes the following error:

DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
DJANGO_SETTINGS_MODULE=boilerroom.settings
55 15 * * * cd /Users/rs/devel_web/virtenv/boilerroom/ && /Users/rs/devel_web/virtenv/dj155_py27/bin/python2.7 /Users/rs/devel_web/virtenv/boilerroom/manage.py test_cron_command

Mail with error message:

X-Cron-Env: <DYLD_LIBRARY_PATH=/usr/local/mysql/lib/>
X-Cron-Env: <DJANGO_SETTINGS_MODULE=boilerroom.settings>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=rs>
X-Cron-Env: <USER=rs>
X-Cron-Env: <HOME=/Users/rs>
Message-Id: <20140704195511.8DDAE2CE8374@tm1.local>
Date: Fri,  4 Jul 2014 15:55:10 -0400 (EDT)

/Users/rs/devel_web/virtenv/dj155_py27/lib/python2.7/site-packages/numexpr-2.4.1.dev-py2.7-macosx-10.9-intel.egg/numexpr/cpuinfo.py:75: UserWarning: [Errno 2] No such file or directory
  stacklevel=stacklevel + 1):

Any help would be greatly appreciated.

Community
  • 1
  • 1
Roland
  • 103
  • 1
  • 1
  • 7

1 Answers1

0

Did you try to activate and deactivate the virtualenv instead of specifying the Python binary? Something like this:

55 15 * * * source /Users/rs/devel_web/virtenv/dj155_py27/bin/activate && cd /Users/rs/devel_web/virtenv/boilerroom/ && python manage.py test_cron_command && deactivate

By the way, I don't understand very well your why do you put your code in virtenv folder, you can separate it.

R.Sicart
  • 671
  • 3
  • 10
  • I just tried it and it made no difference. I still get the `stacklevel + 1` error. – Roland Jul 05 '14 at 12:06
  • I put my code in a virtualenv so that I can have different development environments with different versions of python and other packages. – Roland Jul 05 '14 at 12:37
  • did you install mysqldb module in the right virtualenv? – R.Sicart Jul 05 '14 at 16:39
  • I'm pretty sure the mysql setup is correct. The environment works fine for development. It seems to be something that Numpy is looking for that it can't find. – Roland Jul 05 '14 at 21:50
  • However, your point is correct; mysql does not seem to be installed in the virtenv. I do have it working in the virtualenv. – Roland Jul 06 '14 at 14:38
  • So you need to install Mysqldb module in your Virtualenv with pip or your favourite package manager: `source /Users/rs/devel_web/virtenv/dj155_py27/bin/activate && pip install Mysqldb` – R.Sicart Jul 06 '14 at 17:10