Skip to content

Instantly share code, notes, and snippets.

@vi vi/vmtouchpoll
Last active Apr 9, 2019

Embed
What would you like to do?
Keep files locked in memory by periodically restarting vmtouch
#!/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
You can’t perform that action at this time.