Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

CentOS 5.5 x86_64

Trying to e-mail a periodic system update with the output of a system temperatures command:

hpasmcli -s "show temp"

Outputs something like:

Sensor   Location              Temp       Threshold
------   --------              ----       ---------
#1        AMBIENT              21C/69F    42C/107F

So, I script this:

hpasmcli -s "show temp" > /tmp/monitorTemp.log &
mail -s "temperature" < /tmp/monitorTemp.log
rm -f /tmp/monitorTemp.log

Set to run every hour in cron

* */1 * * * /root/

I receive the e-mail, but it's empty. However, if I simply run it from the command line ./ it sends me the e-mail with command output included!

What am I missing?

share|improve this question

migrated from Nov 17 '10 at 7:03

This question came from our site for computer enthusiasts and power users.

You can eliminate the temporary file: /path/to/hpasmcli -s "show temp" | mail -s "temperature" - the whole script on one line (plus the shebang). – Dennis Williamson Nov 17 '10 at 4:17

Try changing this:

hpasmcli -s "show temp" > /tmp/monitorTemp.log &


cd /path/to/hpasmcli
./hpasmcli -s "show temp" > /tmp/monitorTemp.log

When running from cron, you don't have the same PATH as when running logged in normally, that's something worth to keeping in mind. You can also change the PATH before

hpasmcli -s "show temp" > /tmp/monitorTemp.log

or something similar. You can get the /path/to/hpasmcli by doing which hpasmcli from your regular command prompt.

EDIT: As Dennis notes in the comments, for simple scripts like this one, there's no need to cd or setup PATH, this would be just fine:

/path/to/hpasmcli -s "show temp" > /tmp/monitorTemp.log
share|improve this answer
Bingo, thank you! – gr33d Nov 16 '10 at 22:03
Cool, glad that was the issue! – Nov 16 '10 at 22:06
Yes, is there any $PATH at all for cron? It is another user? – gr33d Nov 16 '10 at 22:08
AFAIK there is some basic path, but it's something like /bin:/usr/bin or something along these lines. – Nov 16 '10 at 22:33
There's no need to cd, just do /path/to/hpasmcli -s "show temp" .... For a simple script, I wouldn't change $PATH either. – Dennis Williamson Nov 17 '10 at 4:14

You can also set a PATH explicitly in your crontab.

eg. PATH=/usr/bin:/usr/sbin:/path/to/executable:. * */1 * * * /root/

But I agree that explicitly setting path in scripts is probably a better solution for one offs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.