Home>

Launch Rails server at specified time using Cent OS7 cron

CROND [7669]: (root) CMD (/root/app/home/rails_server_start.sh)
CROND [7668]: (root) CMDOUT (/root/app/home/rails_server_start.sh: line 2: rails: command not found)
Applicable source code
#Rails Server Start
25 0 * * * root /root/app/home/rails_server_start.sh
rails_server_start.sh
#!/bin/bash
rails s -d --binding = 0.0.0.0
What I tried

I checked variously and it seems that the path may not be passed, so Ruby's path is probably through.I arrived at bash_profile, but I am not sure how to pass Ruby's path to cron, I am in trouble. ..

# .bash_profile
# Get the aliases and functions
if [-f ~/.bashrc];then
    . ~/.bashrc
fi
# User specific environment and startup programs
PATH = $PATH: $HOME/bin
export PATH
export PATH = "$HOME/.rbenv/bin: $PATH"
eval "$(rbenv init-)"
export PATH = "/ usr/bin/mysql/bin: $PATH"
Supplemental information (FW/tool version, etc.)

Cent OS7
Ruby 2.6.5
Rails 6.0.1

  • Answer # 1

    .bash_profile3 lines afterrails_server_start.shI will also write.