I was trying to take database dump using:

redis-cli --csv BGSAVE
CURR_DATE=$(date +%s)
while true; do
    # LASTSAVE returns epoch of last successfull background dump process
    LAST_SAVE=$(redis-cli  --csv LASTSAVE)
    [ "$LAST_SAVE" -ge "$CURR_DATE" ] && break || sleep 30
done

It did not exit from While loop, because LAST_SAVE did not change and it tried to save data into disk,but it failed

Reason: Their was not an available Storage space, and Redis was trying to put new dump data.

Suggestion: Their should be a time out with error message Server out of disk, and program should exit with error code

Comment From: itamarhaber

Hello @AhmedMItman

I don't agree this is a bug with the cli. Your script could be improved to detect a faulty save by calling INFO persistence and looking at the 'rdb_last_bgsave_status' field.

Their should be a time out

What time out? Both BGSAVE and LASTSAVE return immediately.

with error message Server out of disk

The error is output to the log.

and program should exit with error code

Which program?

Comment From: AhmedMItman

Hi @itamarhaber Sorry for the late response, Program : Jenkins Linux Shell I will try INFO persistence with my script and i will back to you Thanks a million