Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script to import PHP session files into redis
#!/bin/bash
export REDISCLI_AUTH=my-supper-strong-password-4-redis-server
TTL=$(( 24 * 3600 ))
# cd "/var/sess"
for i in sess_*; do
ex=$(( $(date +%s) - $(stat -c %Y "$i") + $TTL ))
k="PHPREDIS_SESSION:${i:5}"
v=$(cat "$i")
echo "SET $k of len:${#v} EX $ex"
redis-cli SET "$k" "$v" EX $ex
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment