Sphinx indexing thinking succeeds on the command line, but Cron fails

I admit that I combined mainly a working production plant on Ubuntu with Capistrano from official docs (which seem to be dated and contain a lot of speculation), and various blog posts of various outdated information. In any case, the last annoying hang is that indexing works when I do it manually (and when deploying, I'm sure), but it doesn't work from Cron.

Here is my crontab:

$ crontab -l # mh dom mon dow command * * * * * cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index >> /var/www/app/current/log/cron.log 2>&1 

Here is the log output (it actually appears 3 times per call):

 Sphinx cannot be found on your system. You may need to configure the following settings in your config/sphinx.yml file: * bin_path * searchd_binary_name * indexer_binary_name For more information, read the documentation: http://freelancing-god.github.com/ts/en/advanced_config.html 

This is when I run the same command manually (also works during registration):

 $ cd /var/www/app/current && /usr/local/bin/rake RAILS_ENV=production thinking_sphinx:index (in /var/www/app/releases/20100729042739) Generating Configuration to /var/www/app/releases/20100729042739/config/production.sphinx.conf Sphinx 0.9.9-release (r2117) Copyright (c) 2001-2009, Andrew Aksyonoff using config file '/var/www/app/releases/20100729042739/config/production.sphinx.conf'... indexing index 'app_core'... collected 5218 docs, 3.9 MB collected 5218 attr values sorted 0.0 Mvalues, 100.0% done sorted 0.7 Mhits, 100.0% done total 5218 docs, 3898744 bytes total 0.616 sec, 6328760 bytes/sec, 8470.28 docs/sec distributed index 'app' can not be directly indexed; skipping. total 3 reads, 0.008 sec, 1110.2 kb/call avg, 2.6 msec/call avg total 15 writes, 0.016 sec, 540.4 kb/call avg, 1.0 msec/call avg rotating indices: succesfully sent SIGHUP to searchd (pid=20101). 

Also appropriate:

 $ which rake /usr/local/bin/rake 

 $ which indexer /usr/local/bin/indexer 
The error is somewhat common, but it smells funny that it works fine from the command line, I suspect something else is weird. I have 2 other mission-critical cron jobs that run rake tasks that look identical and run fine, not sure what different about this one. Any help would be greatly appreciated!

PS - is there an authoritarian deployment version for this with current versions of Capistrano and TS? Everyone seems to roll on their own, and the official docs seem as peculiar as the blog posts.

+4
source share
2 answers

Is crontab owned by the same user as the one you are logged in with when you start manually?

Since this seems like an obvious PATH problem, and cron works with a limited PATH (i.e. not in your .profile), try adding this to the top of your crontab file.

 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 

Or, if you do not want to change the cron PATH, you can symbolize the files you need in / usr / sbin, which is probably the default PATH.

+6
source

I can confirm that I had a similar error, for example @kbighorse, where the commands were executed perfectly manually on the command line, but not from the cron job. I did not get any errors, but the log file returned only the directory from which the sphinx command was run. When I add the following path variable from @jdl to the top of the crontab file, the cron job will work correctly:

 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin 
0
source

All Articles