While banging my head on RVM + Rails 3 + crontabs, it became clear that I needed the cron environment in an interactive shell. It’s not hard:
|
1 2 |
sudo su env -i /bin/sh |
If your SHELL in your crontab is /bin/bash:
|
1 2 |
sudo su env -i /bin/bash --noprofile --norc |
Remember that the cron-invoked shell won’t have a tty, so some commands will behave differently. Also, if you’ve got a bunch of other environment variables set up in your crontab, you can do this trick from stackoverflow — create a one-off cron that writes env to a file, and load that env later.