T
T
TestVDK2014-02-22 03:34:49
linux
TestVDK, 2014-02-22 03:34:49

How to setup cron for ruby ​​script?

Hello
At the moment there was a need to put the ruby ​​script on periodic execution
Heard about the cron scheduler
Now I work as root,
PATH variable

/usr/local/rvm/gems/ruby-2.0.0-p353/bin:/usr/local/rvm/gems/[email protected]/bin:/usr/local/rvm/rubies/ruby-2.0.0-p353/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/postgresql/9.3/bin:/usr/local/rvm/bin:

Ruby is installed via RVM
In the file ~/.bashprofile I add a line
source /etc/profile.d/rvm.sh
to crontab -e
* * * * * ruby /var/www/nw/x.rb
I get in /var/www/syslog
(root) CMD (ruby /var/www/nw/x.rb)
No cron logs are configured - the following line
(CRON) info (No MTA installed, discarding output)
Script actions are not executed
If you write ruby ​​x.rb in the console - the script works, but not su root ruby ​​x.rb - writes "ruby: no such file or directory"
How to solve this problem, what and where should be added?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene Burmakin, 2014-02-25
@Freika

And gem Whenever will not solve your problem? A very handy thing, in my opinion.

F
FanKiLL, 2014-02-22
@FanKiLL

You need the full path to the interpreter, for example
in your case, .rbenvyou need to put the interpreter from the .rvmfolder instead.
Look at Using RVM with Cron

N
Nikolai Turnaviotov, 2014-02-22
@foxmuldercp

in your version, there is an interpreter and then the command
and it takes time, then the user (if the system /etc/crontab) then the full path to the interpreter and the argument to it the full path to the desired script.
also check the permissions so that the script can be executed.
and configure mta, at least nullmailer, so that system operation logs are sent to mail.
man cron:
# mh dom mon dow user command
0 23 * * * root /bin/bash /full/path/to/my/script.sh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question