I want to find any/all redis keys with TTL is -1
. That's every key that is not set to expire. I've tried a couple GUI clients and none of them seem to off this functionality.
I found this answer which appears to offer a way to do it from the command line. But I get "invalid argument" errors when I try it locally or on my remote redis host.
LOCAL
redis-cli keys "*" | while read LINE ; do TTL=`redis-cli ttl $LINE`; if [ $TTL -eq -1 ]; then echo "$LINE"; fi; done;
REMOTE
$redis-cli -h ... -p ... -a
redis>> keys "*" | while read LINE ; do TTL=`redis-cli ttl $LINE`; if [ $TTL -eq -1 ]; then echo "$LINE"; fi; done;
What am I doing wrong? Is there a better way to do this?