Created
May 22, 2020 16:42
-
-
Save imgeraldalinio/b5a4c9f1b1ff44a7bffc5fdeafc1b2dc to your computer and use it in GitHub Desktop.
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 | |
# 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