Issue
#!/bin/bash
#!/usr/bin/env ruby
cd /var/www/project
if [ ! -f tmp/pids/delayed_job.pid ]; then
echo "File not found!"
pwd
./bin/delayed_job start
echo "Run script successful!"
fi
In my code start normally is work but run with crontab not work.
any idea pls.
Solution
It solved.
I'm use rbenv for ruby install and setup it in to .bash_profile. Yes environment work but i run ruby in crontab not work.
Solution: I copy some config in .bash_profile to my script see below
#!/bin/sh
#below script from .bash_profile
PATH=$PATH:$HOME/bin
export PATH
export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
#end script from .bash_profile
RAILS_HOME="/var/www/{project}"
if [ ! -f $RAILS_HOME/tmp/pids/delayed_job.pid ]; then
echo "Starting Delayed job"
$RAILS_HOME/bin/delayed_job start
fi
Answered By - Mr.Tom Answer Checked By - Mary Flores (WPSolving Volunteer)