[Info] Exposing environment variables in crontab

crontab runs in a very 'scarce' environment,. When adding a script in crontab, the environment variables are not exposed the same way as when you log normally from console.

To expose the environment variables (like PATH, etc) same way as when you login from console, you need to use the bash 'login' option when running the command.

For example, this line in crontab:

@reboot /app/start_remote_agent.sh

would become:

@reboot bash -l -c /app/start_remote_agent.sh

References:

http://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths

Attached Files
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Name
Email
Security Code Security Code
Related Articles RSS Feed
MENU