I have a shell script which updates different firmwares with different executables. I need to know if one of the executable has hung and not returning back to shell. Can I introduce any kind of timeout ?
Sample shell script below. How to handle if updatefw command hangs and does not return.
#!/bin/sh
updatefw -c config.cfg
if [ $? != 0 ]; then
echo "exec1 failed"
exit 1
fi
exit 0
I suggest with timeout from GNU core utilities:
When
timeoutquitsupdatefw, the return code is 124.I assume here that the update will never take longer than 30 seconds.