Use env to ensure a script will work in cron

I’ve often written scripts only to discover once added to crontab that it relies on an environment setting such as having the java command in the PATH or having CVSROOT set. To avoid this I now run scripts I’m developing for cron with env -i to simulate the script running without an environment as follows:

env -i somescript.sh

This has greatly increased my success rate of adding a script to cron and having it work from the get go.

This entry was posted in Systems Administration. Bookmark the permalink.

One Response to Use env to ensure a script will work in cron

  1. Pingback: Tagz | "Use env to ensure a script will work in cron" | Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>