Script run by cron gives no output

Hi All,

I have a script which checks the status of HP Smart Array & then emails me the output.
The script run fine when executed manually but I receive no output when configured in a cron job.

The script is below:

hpacucli ctrl slot=3 show config | mail -s "ARRAY STATUS-`date`" me@mycompanyemail.com

Please help me on this.

Make sure that the environement variables required are setup from within the script you call. (Cron may not preserve some of the environment variables that you need to run your script).

Also you can put your command line into a single script and call it from crontab.
( Not sure it is correct, but otherwise, you can give a try putting your command line in parenthesis)

1 Like

Use absolute path for hpacucli. Replace highlighted with actual path:

/path_to_hpacucli/hpacucli ctrl slot=3 show config | mail -s "ARRAY STATUS-$(date)" me@mycompanyemail.com
1 Like

Errors are more important than output, catch them and use it appropriately.

AFAIR the command

hpacucli controller all show config

will not show a just failed disk; it only shows a bad battery, a failed self-test, and a failed disk at system start.
Safer for continued monitoring is the command

hpacucli controller all show config detail

and look at the Status: lines.
The later versions of hpacucli are named hpssacli

It works man !!Thanks.

---------- Post updated at 10:24 AM ---------- Previous update was at 10:19 AM ----------

output of my command

/usr/sbin/hpacucli ctrl slot=3 show config 

is

Smart Array P212 in Slot 3                (sn: PACCP9SXUVVW  )     array A (SATA, Unused Space: 0  MB)         logicaldrive 1 (465.7 GB, RAID 1, OK)        physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SATA, 500 GB, OK)       physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SATA, 500 GB, OK) 

am getting some doubts on this command now..are you saying that when one of the drive fails it won't tell me ??? pls advise.

am on debian lenny 5 (x64)

Maybe I don't remember correctly.
Your output sais "physicaldrive", that looks okay.