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

Comments are closed.