Crontab not running ruby script

后端 未结 5 829
眼角桃花
眼角桃花 2021-02-15 15:15

The crontab -l below doesn\'t seem to run. The script run by hand runs fine. Here is the error i\'m seeing

Dec  3 20:12:01 dahlia /USR/SBIN/CRON[13912]: (gigawat         


        
5条回答
  •  失恋的感觉
    2021-02-15 15:53

    This is quite old but thought I'd comment anyway. RVM creates a wrapper for each version of ruby you install.

    run this command replace 2.5.1 with your ruby version

    rvm env --path 2.5.1
    

    this gives you the path to the environment mine is

    /home/username/.rvm/environments/2.5.1

    you want just the rvm path

    /home/username/.rvm/

    take a look at the wrappers directory there should be a wrapper for each version and gemset you have installed. Test your script with the wrapper

    /home/username/.rvm/wrappers/ruby-2.5.1/ruby /home/username/scripts/script.rb
    

    or if you have a specific gemset

    /home/username/.rvm/wrappers/ruby-2.5.1@gemset/ruby /home/username/scripts/script.rb
    

    Use this command directly in your crontab

    * * * * * /home/username/.rvm/wrappers/ruby-2.5.1/ruby /home/username/scripts/script.rb
    

提交回复
热议问题