Last active
April 9, 2019 06:04
-
-
Save vi/77717d7076618af92344 to your computer and use it in GitHub Desktop.
Keep files locked in memory by periodically restarting vmtouch
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 | |
# vmtouchpoll: Keep some files locked in memory (including new files, dropping deleted files) | |
# Usage: vmtouchpoll '/path/to/some/files/*.idx' | |
# Works by periodically restarting vmtouch with a new set of files | |
# Implemented by Vitaly "_Vi" Shukela in 2015, License=MIT | |
F=($(eval echo $1)) | |
vmtouch -L -m 2G "${F[@]}"& | |
P1=$! | |
P2=0 | |
disown | |
trap 'kill $P1; [[ $P2 -gt 0 ]] && kill $P2' EXIT | |
while true; do | |
sleep 55; | |
F=($(eval echo $1)) | |
vmtouch -q -L -m 2G "${F[@]}"& | |
P2=$! | |
disown | |
sleep 5; | |
kill $P1 | |
P1=$P2 | |
P2=0 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment