bashlsof

Timeout in Shell Script


Using Shell Script like below:

if [[timeout 60 | wsof -l]]; then echo "thread sleeping for 60 seconds" exit else echo "timeout failed" exit fi

But getting error timeout failed. How to apply timeout for 60 seconds so that return is echo "thread sleeping" in this case? I'm using bash script for this Case


Solution

  • I'm not sure what |wsof -l is supposed to do, but it may not be working properly because of the brackets (it doesn't work for me when I do it with brackets, but when I do it without it only errors out at the wsof -l command, which I assume you made).