LoginSignup
25
24

More than 5 years have passed since last update.

cronからbundle exec...はsu - <USER> -lc ...が一番便利

Last updated at Posted at 2014-08-16

って自分は思ったのですが、みなさんはどうやってるんでしょうか?

0 */1 * * * root su - <USER_NAME> -lc "cd /home/<USER_NAME>/yourproject_path && bundle exec ruby hoge.rb" >> /var/log/yourproject/cron/hoge.log 2>&1

ちなみに実行するユーザーである<USER_NAME>.bash*とかにruby関連の設定が書いてある前提です。

rbenvだったら

.bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

xbuildとかで入れてるなら

.bashrc
export PATH=$HOME/local/ruby-2.1/bin:$PATH
25
24
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
24