Using global environment variables inside a subshell

Steve Bertrand steve at
Wed Oct 1 13:53:05 UTC 2008

Hi everyone,

I've fudged together a quick disk space monitor that I will run from
cron. Running the script works fine from the command line, but when I
run it from cron, the environment variable is empty.

Can someone point out the err of my ways?:


/bin/df | \
/usr/bin/awk '{if($5 ~ "%" && $6 !~ "proc") {used=$5} else {used=""}; \
sub(/%/, "", used); \
if(used > 95) print $6 " is at " used"% on "ENVIRON["HOSTNAME"]"!"}' | \
mail -s "Disk usage action required" email at



More information about the freebsd-questions mailing list