use env to test scripts for cron and monit

I’ve used /usr/bin/env for years but I just realized today that it can be very useful for testing processes that are run with cron or monit.

env has a nice option for clearing out all of the environment variables:

-i, --ignore-environment - start with an empty environment

Now you can try to run your script in an environment very similar to cron or monit. Note that this option even clears the PATH so you need to specify full paths or specify a PATH variable.

/usr/bin/env -i HOME=/path/to/my/home /path/to/do_script.sh

Share:
  • del.icio.us
  • Reddit
  • Technorati
  • Twitter
  • Facebook
  • Google Bookmarks
  • HackerNews
  • PDF
  • RSS
This entry was posted in sysadmin. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.