24
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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
24
23
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
24
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?