I use the following if ... then test in an auto shutdown script which is started every 15 minutes by cron.
# Check if disk1 is currently spinning
if [ "$(hdparm -C /dev/sdb1 | grep -o "active/idle\|standby")" = "active/i$
logit disk1 running, auto shutdown terminated
return 1
This works fine if I start the script manually with ./autoshutdown.sh
. The disk state will be detected correctly.
But if cron is starting this script and the state is not detected the else statement is used.
Why this difference? And what do I need to change?
$PATH
differs in cron jobs, and it cannot findhdparm
. SPecify the whole path tohdparm
, which you can find viatype -p hdparm
.