Last active
July 4, 2019 10:36
-
-
Save duzun/ca63b73672bb19a5ca6cbd92e98ebbc3 to your computer and use it in GitHub Desktop.
Bash script to import PHP session files into redis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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