Temur
Temur

Reputation: 21

run command from folder via cron

I wrote this task for cron:

0 * * * * cd ~/projects/stat-eprorok-rails4/current && rvm use 2.0.0 do bundle exec rake vk_posts:update_likes RAILS_ENV=production

I do not understand why the task is not performed every hour, because this script works:

cd ~/projects/stat-eprorok-rails4/current && rvm use 2.0.0 do bundle exec rake vk_posts:update_likes RAILS_ENV=production

Upvotes: 0

Views: 78

Answers (2)

Zoltán Haindrich
Zoltán Haindrich

Reputation: 1808

the tilde(shorthand for home) might not have been initialized...try it with absolute path

Upvotes: 1

stmfunk
stmfunk

Reputation: 683

The cd method is not designed for use with an application like cron, you need to use the full path for each command you want to run in that directory. For every file operation include the full file path.

Upvotes: 0

Related Questions