Skip to content

Instantly share code, notes, and snippets.

@libbkmz
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save libbkmz/8791444 to your computer and use it in GitHub Desktop.

Select an option

Save libbkmz/8791444 to your computer and use it in GitHub Desktop.
Remove PHP session files from mod-tmp. ISPManager
BEGIN{
system("ionice -c3 -p " PROCINFO["pid"]);
system("renice -n 19 -p " PROCINFO["pid"]);
dir_len = 0
while ("ls -1 /var/www" | getline) {
dirs[dir_len++] = $0
}
for(i=0;i<dir_len;i++){
path = "/var/www/" dirs[i] "/data/mod-tmp2";
command = "ls -1f " path
print command
print counter2
LIMIT = 32;
limit = limit;
sleep_time = 8;
counter1 = 0;
counter2 = 0;
file_list = "";
while (command | getline){
if ($0 == "." || $0 == ".."){
continue;
}
# system("rm " path "/" $0);
file_list = file_list " " path "/" $0;
counter1++;counter2++;
printf "%i\r", counter1;
if (limit-- <= 0){
system("rm " file_list);
file_list = "";
print counter2;
counter1 = 0;
limit = LIMIT;
system("sleep " sleep_time);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment