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
No Comments, Comment or Ping
Reply to “use env to test scripts for cron and monit”