Reputation: 71
I've below command in crontab, when I run this command in terminal it works fine but when I run this in crontab am getting the following error
* * * * * cd /home/path/application && RAILS_ENV=development ./bundle exec rake namespacefolder:rake_file
Error:
bundler: command not found: rake
Install missing gem executables with `bundle install`
someone please help.
Upvotes: 0
Views: 151
Reputation: 23671
Try this one if not solved with bundle
* * * * * /bin/bash -l -c "cd ~/home/path/application && RAILS_ENV=development bundle exec rake namespacefolder:rake_file"
/bin/bash
Specify which program to use for executing the command
-c
Read and execute commands from the first non-option argument after processing the options, then exit. Any remaining arguments are assigned to the positional parameters, starting with $0.
-l
Make this shell act as if it had been directly invoked by login. When the shell is interactive, this is equivalent to starting a login shell with ‘exec -l bash’. When the shell is not interactive, the login shell startup files will be executed. ‘exec bash -l’ or ‘exec bash --login’ will replace the current shell with a Bash login shell. See Bash Startup Files, for a description of the special behavior of a login shell.
Refer this documentation here
Upvotes: 0
Reputation: 23
Cron passes only minimal set of environment variables to your jobs. See here!
Add -lc option to bash for cron execution to use your login environment and set environment path at the top of your crontab.
PATH=$PATH:/usr/bin:/bin:/usr/local/bin
* * * * * /bin/bash -lc "cd ~/home/path/application && RAILS_ENV=development bundle exec rake namespacefolder:rake_file"
Upvotes: 2