Skip to content

Instantly share code, notes, and snippets.

@imgeraldalinio
Created May 22, 2020 16:42
Show Gist options
  • Save imgeraldalinio/b5a4c9f1b1ff44a7bffc5fdeafc1b2dc to your computer and use it in GitHub Desktop.
Save imgeraldalinio/b5a4c9f1b1ff44a7bffc5fdeafc1b2dc to your computer and use it in GitHub Desktop.
#!/bin/bash
# clean up PHP files from tmp directory older than 5 hours
sudo find /tmp/php* -type f -mmin +300 -type f -ls -delete
# sort deleted files and filter PID numbers by unique value
clean=`sudo /usr/bin/lsof | grep deleted | awk '{print $2}' | sort | uniq`
# loop PID numbers
for i in $clean
do
echo "Kill PID number $i"
# deleting running PID numbers
sudo kill -9 $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment