Reputation: 4634
For some kind of reason, I can't use ruby
in crontab
.
In the console, if I run echo $(ruby -v)
, it will return the version of ruby
perfectly.
However, I put the following code in crontab
* * * * * echo $(ruby -v) >> 123.rb
* * * * * echo "123" >> 123.rb
Then I notice that, the 123.rb
only contains a lot of 123
.
So I checked the path of ruby
.
root@myserver:~# which ruby
/usr/share/rvm/rubies/ruby-2.3.3/bin/ruby
Basically, I am the only one user who can access this server, so I install all application as root
.
Should I and how do I add some link
to enable the permission for root
?
Upvotes: 0
Views: 52
Reputation: 1838
In crontab, type full pathes:
* * * * * echo $(/usr/share/rvm/rubies/ruby-2.3.3/bin/ruby -v) >> 123.rb
* * * * * echo "123" >> 123.rb
should work.
Or, add $PATH
variable:
In console:
echo $PATH
Copy value, in crontab file add:
export $PATH="<copied pathes>:/usr/share/rvm/rubies/ruby-2.3.3/bin/"
* * * * * echo $(ruby -v) >> 123.rb
* * * * * echo "123" >> 123.rb
Upvotes: 2