我在/ home / myuser / watchDir / myapp中有一个rails应用程序,并设置了一个incron作业来监视../watchDir进行修改。触发后,incron将运行一个脚本/usr/local/bin/myscript.sh。这是我唯一可以从中运行脚本的地方。在该脚本中,我调用了在我的根应用程序中运行rake
和bundle
命令。我正在运行脚本(我有一个测试),但bundle
和rake
命令都无声地失败。我对Linux很新,互联网研究已经给出了一些解决方案。我的脚本中有所有绝对路径。我尝试将我的bash_profile添加到scripts / incron命令中。我尝试让incron脚本运行位于我的主目录中的另一个脚本。所有脚本都是可执行的。我尝试使用--gemfile
的{{1}}选项,但这并不重要。有谁知道我在这里要做什么?基本上,我想在RAILS_ROOT之外运行bundle
和bundle
命令。我还想知道incron是否使rails命令的使用变得复杂。感谢。
编辑:
以下是相关文件:
Incrontab:
rake
我也试过这个:
/home/myuser/watchDir/ IN_MODIFY,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE /bin/bash /usr/local/bin/runT.sh $@/$#
以下是它所说的剧本:
/home/myuser/watchDir/ IN_MODIFY,IN_CLOSE,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE source '/home/myuser/.bash_profile && /bin/sh /usr/local/bin/runT.sh' $@/$#
我的.bash_profile文件:
#!/bin/bash
mkdir /home/myuser/worked #This is to ensure that that incron is running and executing this script
cd /home/myuser/watchDir/myapp
/home/myuser/.rvm/gems/ruby-1.9.3-p545/bin/bundle install --gemfile /home/myuser/watchDir/myApp/Gemfile
/home/myuser/.rvm/gems/ruby-1.9.3-p545/bin/rake -f /home/myUser/watchDir/myApp
答案 0 :(得分:1)
总结我的上一次评论......将您的icrontab
条目更改为:
/home/myuser/watchDir/ IN_MODIFY,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE /bin/bash /usr/local/bin/runT.sh $@/$#
脚本是:
#!/bin/bash
source /home/myuser/.bash_profile
mkdir /home/myuser/worked #This is to ensure that that incron is running and executing this script
cd /home/myuser/watchDir/myapp
/home/myuser/.rvm/gems/ruby-1.9.3-p545/bin/bundle install --gemfile /home/myuser/watchDir/myApp/Gemfile
#/home/myuser/.rvm/gems/ruby-1.9.3-p545/bin/rake -f /home/myUser/watchDir/myApp