I want to retry a command for 5 times with an interval of 20 seconds. I want this command to be passed as a method parameter. How to do it? And once the function is written how to pass the value to the function?
I want my current code to be converted to a function which takes a set of parameters. How to write and call this function in my shell script?
My current code is like this :
trialNumber=0 until [ $trialNumber -ge 5] do ssh $USERID@$HOST $SCRIPT_LOCATION/runme.sh # This line is my command and it may very with number of parameters or command itself. [ $? -eq 0 ] && break trialNumber=$[$trialNumber+1] sleep 20 done
( Above code is embedded at many places I want to move it into a function).