Say below is my code for logging and fs_ck function
if script fails at fs_ck function then script should remember this and next time i execute my script it should start from failed point
function logging {
ssh abc@def
if [[ $? -eq 0 ]]; then
echo "Successfull"
else
echo "Failure"
fi
}
function fs_ck {
A=`ssh abc@def df -kh . | awk '{print $5}' | tail -1`
A="${A:0:2}"
if [ $A -lt 85 ];then
echo " space issues"
else
echo " fine"
fi
}
This question has been covered before in these forums; try searching for proposed solutions. This is one of the possible search results.
You could work with - let's call it - "status files". When a function has finished satisfactorily, touch a result file, and skip execution of the function if it exists, like
bkp () { touch ${FUNCNAME[0]}.done; }
logging () { touch ${FUNCNAME[0]}.done; }
dply () { touch ${FUNCNAME[0]}.done; }
fs_ck () { if false; then touch ${FUNCNAME[0]}.done; else return $?; fi }
for FN in logging fs_ck bkp dply; do [ -f "${FN}.done" ] || { if ! ${FN}; then echo $?; break; fi; }; done
This will execute your functions in the desired order if the result file does not exist. For fs_ck it will fail, won't create the result file, and start over with fs_ck skipping the logging function. Give it a try and report back.