Load login shell inside user cronjob
Posted
by
sa125
on Super User
See other posts from Super User
or by sa125
Published on 2012-08-20T06:49:38Z
Indexed on
2012/09/03
9:40 UTC
Read the original article
Hit count: 357
I'm trying to run a rake task using a scheduled cronjob. My crontab looks something like this:
0 1 * * 1-7 /bin/bash -l -c "cd ~/jobs/rake && rake reports:create >> ~/jobs/logs/cron.log"
Ruby on my account is provided by RVM, which is loaded via ~/.bashrc
(before the no-interaction check):
# load RVM env
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# ... rest of logic
Time and again, this task fails to run since RVM isn't loaded when the task is called (uses system's /usr/bin/ruby
instead), and gem dependencies are missing.
How can I make crontab load my shell environment before executing my scheduled jobs? thanks.
© Super User or respective owner