Created
May 28, 2015 12:28
-
-
Save bitcloud/52ba86060f815e9d9133 to your computer and use it in GitHub Desktop.
If you have a TimeMachine on a NAS oder Linux Server, sometimes it tells you that the sparsbundle is already in use. This small script cleans up old AFP connections that are already dead. Change the PROCOWNER to the afpd root process owner.
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 | |
PROCOWNER=admin | |
for PID in $(ps waux | grep afpd | grep -v $PROCOWNER | awk '{print $1}') | |
do | |
echo "==> checking pid $PID"; | |
lsof -i | grep afp | grep -v $PROCOWNER | awk '{print $2}' | grep $PID > /dev/null | |
if [ $? -ne 0 ]; | |
then | |
ps waux | grep $PID | grep -v $PROCOWNER | |
#lsof | grep $PID | grep afpd | grep MD0_DATA | |
echo -n "! already dead. killing $PID ... " | |
kill $PID | |
PID='' | |
echo "done." | |
else | |
echo "still alive." | |
fi | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment