0

I am trying to set time out for df command and kill the command if its time out,

use: Its for a script to check df output but some times if df hung the script also get hung.

I tried

TIMEOUT=10
df -hTP & PID=$!
wait $PID $TIMEOUT
if [ $? -eq 0 ]; then
    cat <&3
  else
    kill $PID
    echo "The df command hung"
fi

But I am getting error

line 166: wait: pid 10 is not a child of this shell error: List of

process IDs must follow -q.

what I am looking

check the df command, if not hung just display df output , if hung just kill df, and continue rest of the script part.

Please help me to fix this.

Regards, Vijay

Cyrus
  • 84,225
  • 14
  • 89
  • 153
vijayedm
  • 15
  • 3

0 Answers0