Ubuntu / Mint gvfsd-metadata kill script.

I’ve always had trouble with gvfsd-metadata. Not that I know what it actually is, I just know that once or twice a day my computer will become unresponsive, and the culprit is this little program running around in the background, doing whatever it does, and pegging my CPU up to 100%. I’ve searched many forums. A lot of people are affected, but there doesn’t really seem to be any solution, or any clear reasons why it happens.

So what I usually do is open up a Terminal, run top and see that gvfsd-metadata is at the top of the list redlining my CPU. From there, I press k to kill it (if its the topmost item, its PID will be automatically selected, otherwise enter the PID manually), and then retain the suggested kill signal value of 15. Not a terribly hard process, but as the CPU is maxed out, then opening a Terminal window and top can take a few minutes. Its that sluggish. So, like you do, I whipped up a quick script to handle this automatically, which I run every 5 minutes. So here it is:

export DISPLAY=:0
# Find PID of gvfsd
GPID=`pidof gvfsd-metadata`
# Get the current CPU% of gvfsd
GCPU=`top -b -n 1 -p $GPID | tail -n 1 | awk '{print $9}'`

# Uncomment the line below to debug
# GCPU=7

# Test if CPU is greater than 5%?

if [ "$(echo $GCPU '>' 5 | bc -l)" = 1 ] 
 # Put a line in syslog
 logger "gvfsd-metadata on PID $GPID is running at $GCPU percent CPU, which is more than 5%. Killing."
 kill -9 $GPID
 # Flash a message onscreen
  /usr/bin/zenity --info --text="Just killed a rampant GVFSD, Sir\!" --title="Gotcha"
 exit 0


OK, that’s pretty much it. I added it to my crontab (gvfsd runs as the user, so no need for root crontab), and set it to go every 5 minutes.
*/5     *       *      *      *   /home/me/scripts/killgvfsd.sh



Leave a Comment