我想执行rake太阳黑子:reindex RAILS_ENV =每四个小时执行一次生产命令。为了实现这一点,我使用shell编程编写了简单的bash脚本。我将在终端成功运行,但如果我试图在crontab中运行它,那么它不起作用。我使用的操作系统是centos。如何在后台每四个小时运行一次sunspot reindex
这里是我的bash脚本代码
#!/bin/bash
#export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH=/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/[email protected]/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:
echo "started"
cd /var/www/html/spotchase2
pwd
source /usr/local/rvm/environments/ruby-1.9.2-p290
bundle install
if [ "$?" = 0 ]; then
echo `date`
fi
source /usr/local/rvm/environments/ruby-1.9.2-p290
#/usr/local/rvm/gems/ruby-1.9.2-p290/bin/rake sunspot:reindex RAILS_ENV=production
rake sunspot:reindex RAILS_ENV=production
if [ "$?" = 0 ]; then
echo "complete"
fi
请帮我解决这个问题。
编辑
我重定向输出一个文本文件。在那个文本文件中只有开始,捆绑安装和日期。我没有收到完整的信息,因此我开始知道它没有工作,并且在该文本文件中没有收到任何错误。
请帮我解决这个问题。
问题是什么?你有错误信息吗?你为什么说它不起作用? – tripleee