{"id":315,"date":"2015-03-13T12:10:02","date_gmt":"2015-03-13T04:10:02","guid":{"rendered":"http:\/\/play.datalude.com\/blog\/?p=315"},"modified":"2015-04-08T15:56:13","modified_gmt":"2015-04-08T07:56:13","slug":"ubuntu-mint-gvfsd-metadata-kill-script","status":"publish","type":"post","link":"https:\/\/play.datalude.com\/blog\/2015\/03\/ubuntu-mint-gvfsd-metadata-kill-script\/","title":{"rendered":"Ubuntu \/ Mint gvfsd-metadata kill script."},"content":{"rendered":"<p>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.<\/p>\n<p>So what I usually do is open up a Terminal, run <em>top <\/em>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 <strong>that<\/strong> sluggish. So, like you do, I whipped up a quick script to handle this automatically, which I run every 5 minutes. <!--more-->So here it is:<\/p>\n<pre><span style=\"font-size: 8pt;\">#!\/bin\/bash<\/span>\r\n<span style=\"font-size: 8pt;\">export DISPLAY=:0<\/span>\r\n<span style=\"font-size: 8pt;\"># Find PID of gvfsd<\/span>\r\n<span style=\"font-size: 8pt;\">GPID=`pidof gvfsd-metadata`<\/span>\r\n<span style=\"font-size: 8pt;\"># Get the current CPU% of gvfsd<\/span>\r\n<span style=\"font-size: 8pt;\">GCPU=`top -b -n 1 -p $GPID | tail -n 1 | awk '{print $9}'`<\/span>\r\n\r\n<span style=\"font-size: 8pt;\"># Uncomment the line below to debug<\/span>\r\n<span style=\"font-size: 8pt;\"># GCPU=7<\/span>\r\n\r\n<span style=\"font-size: 8pt;\"># Test if CPU is greater than 5%?<\/span>\r\n\r\n<span style=\"font-size: 8pt;\">if [ \"$(echo $GCPU '&gt;' 5 | bc -l)\" = 1 ] <\/span>\r\n<span style=\"font-size: 8pt;\">then<\/span>\r\n<span style=\"font-size: 8pt;\">\u00a0# Put a line in syslog<\/span>\r\n<span style=\"font-size: 8pt;\">\u00a0logger \"gvfsd-metadata on PID $GPID is running at $GCPU percent CPU, which is more than 5%. Killing.\"<\/span>\r\n<span style=\"font-size: 8pt;\">\u00a0kill -9 $GPID<\/span>\r\n<span style=\"font-size: 8pt;\">\u00a0# Flash a message onscreen<\/span>\r\n<span style=\"font-size: 8pt;\">\u00a0 \/usr\/bin\/zenity --info --text=\"Just killed a rampant GVFSD, Sir\\!\" --title=\"Gotcha\"<\/span>\r\n<span style=\"font-size: 8pt;\">else<\/span>\r\n<span style=\"font-size: 8pt;\">\u00a0exit 0<\/span>\r\n<span style=\"font-size: 8pt;\">fi<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>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.<br \/>\n*\/5\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 \/home\/me\/scripts\/killgvfsd.sh<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. &#8230; <a title=\"Ubuntu \/ Mint gvfsd-metadata kill script.\" class=\"read-more\" href=\"https:\/\/play.datalude.com\/blog\/2015\/03\/ubuntu-mint-gvfsd-metadata-kill-script\/\" aria-label=\"Read more about Ubuntu \/ Mint gvfsd-metadata kill script.\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,4],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-it","category-linux"],"_links":{"self":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":0,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"wp:attachment":[{"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/play.datalude.com\/blog\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}