I have a cron job set to execute a shell script telling the server to run a single ruby command (jekyll build --source /path/to/source/dir --destination /path/to/dest/dir
) 2 minutes past every hour. The script executes just fine when I run it via the terminal, but cron doesn't seem to fire it. I know cron's environment isn't the same as the user's and I've set its source path to my .bash_profile
, where the user ruby environment is defined, as per advice elsewhere. I'm rather at a loss now.
The crontab entry looks like this:
2 * * * * . $HOME/.bash_profile ~/jek.sh
FWIW, the relevant section of .bash_profile
, set up automatically when RVM was installed (on shared hosting, with somewhat outdated ruby no less, getting Jekyll up and running without being able to write to the server's own ruby directory means using RVM; this seems to work absolutely fine), is:
PATH=$PATH:$HOME/bin
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Am I calling my user profile for use in the cron environment wrongly? Am I missing something glaringly obvious in the syntax? Any help would be much appreciated.