Fix ‘Folder Actions Dispatcher’ using high CPU in Yosemite

ActivityMonitorIconXAfter upgrading to OS X Yosemite, you might find your system running rather slowly, even when there are no obvious reasons for it, such as a program you have open that is performing some computationally intensive task. Upon investigating this, you might resort to opening Apple’s Activity Monitor program to see what is running in the background, and find a process called Folder Actions Dispatcher running and using between 80 to 100 percent of your CPU.

If this happens, then it is likely because at some point you or a program you installed set up folder actions on your Mac. These are a rather unused feature of OS X, but are quite useful for monitoring changes to folders for the sake of automating tasks using AppleScript and Automator, including a security approach I recommend to keep tabs on various system folders that malware developers use for storing launcher scripts to keep their malware running in the background.

While they have their uses, folder actions are not too well supported by Apple, and seem to be somewhat on the back-burner when it comes to importance. In this case, it appears in Yosemite there is a bug with how Folder Actions are handled, where the Folder Actions Dispatcher seems to be stuck in some sort of loop when monitoring folders, and this causes it to use far more system resources than it ought to.

Fixing this problem will require Apple’s engineers to issue an update for Folder Actions; however, until then, you can overcome it by disabling Folder Actions on your Mac:

  1. Open the Script Editor utility in your Applications > Utilities folder
  2. Go to the Script Editor’s Preferences (press Command-comma in the program)
  3. Ensure “Show Script menu in menu bar” is enabled
  4. Go to the script menu, which looks like a small scroll of paper
  5. Select Folder Actions > Configure Folder Actions
  6. Uncheck the box in the window that appears for “Enable Folder Actions”

An alternative to the last two steps is to simply select the Disable Folder Actions script that should be in the same Folder Actions submenu as the configuration utility. With either of these two done, Folder Actions should be disabled and you should see your CPU usage drop from the dispatcher process.

(UPDATE: MacIssues reader “Mike” wrote in with a suggestion to try simply toggling Folder Actions off and then back on again using the options in the Folder Actions menu, to see if this fixes the problem and allows you to continue using your configured Folder Actions.)

Folder Actions submenu in OS X

Use these options in the Folder Actions submenu to manage your folder actions.

Unfortunately, with this feature disabled, you will not be able to automate tasks as easily. One alternative to folder actions is to set up launch daemon scripts, which have options to set up watch paths that will trigger the launching of programs and alternative scripts; however, this does require you use Terminal commands and editors to create XML property list launch agent files.

If you are familiar with these, then you can use the following property list template to launch a given program or script whenever the folders specified in the script are changed (I will outline how to do this in-depth in a follow-up article):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>FolderActions</string>
     <key>ProgramArguments</key>
     <array>
          <string>/path/to/script/or/program</string>
     </array>
     <key>WatchPaths</key>
     <array>
          <string>/Full/Path/to/first/monitored/folder</string>
          <string>/Full/Path/to/second/monitored/folder</string>
          <string>/Full/Path/to/third/monitored/folder</string>
     </array>
</dict>
</plist>

Using TextEdit to save this plist structure in a plain text (not rich text) document named “folderactions.plist,” and placed in your username/Library/LaunchAgents folder (logging out and back in is an easy way to activate the agent) will watch the paths listed in the WatchPaths section for any changes, and then invoke the first ProgramArguments string as a command. This program can be an application, an applescript, an Automator Workflow, shell script, or other utility, each of which may take slightly different syntax here for running, but all of which can be invoked in the ProgramArguments section.

The main problem with using this approach is that filesystem events may not always be complete when WatchPaths is triggered, so the launch agent may run even when small updates are made to folders, or it may miss some updates altogether; however, it is the best alternative to a buggy Folder Actions in Yosemite.

11 thoughts on “Fix ‘Folder Actions Dispatcher’ using high CPU in Yosemite

  1. Vic

    Another reason not to upgrade to Yosemite. Seriously, Apple’s software engineering quality these days is just disgraceful. I’ve been using Macs since 1984 and I don’t recall it ever being so bad. Let’s hope they get it sorted.

    Reply
  2. Kurt J. Meyer

    What a coincidence: Just yesterday I found the reason for an issue that I had seen only in and therefore associated with Yosemite, but in fact was caused by an AppleScript, that an utility had connected as a folder action to my /Volumes folder back in the year 2009. (It was an Open Source application named iTuneMyWalkman, intended to synch Music to Sony Ericsson phones whenever they were mounted on the Mac.) I had forgotten it totally. In Yosemite, every mounting of a volume now triggered the Automator gear appearing in the menu bar for a lengthy (fruitless) process, and I remember that I saw the Folder Action Dispatcher process hanging then. — Yesterday I deleted that script as well as its connection as a folder action to my /Volumes folder.

    Reply
  3. Randy Singer

    This probably at least partially explains why users who upgrade to Yosemite via a clean install don’t see most of the problems that some others do. In fact, users who have upgraded to Yosemite via a clean install almost uniformly report that their Mac is faster than ever before, and that it is easy on RAM.

    Reply
  4. visionaut

    This bug with the Folder Actions Dispatcher ‘running amok’ does not affect ALL Folder Action scripts. Many folders can be watched via Folder Actions with no issues. The excessive CPU happens when monitoring a particular folder: the user’s ~/Library/LaunchAgents folder.

    The bug is due to a Folder Actions plist file in that folder that updates constantly – causing a crazy feedback loop and the runaway condition. None of the other LaunchAgents or LaunchDaemon folders on a system are affected – the others can still be monitored without problem. Apple seems to be aware of the bug, and working a fix, BTW.

    Hope this helps.

    Reply
    1. nmt1900

      I noticed same problem almost immediately after upgrading to Yosemite. Then I tried to troubleshoot the problem and came to same conclusion – other folders can safely be left enabled excluding the one where Folder Actions plist resides.

      Reply
  5. Alan Coleman

    I clean installed and had the same problem with Folder Actions, not only using excessive cpu but also eating up all my ram and crashing my Mac.
    The same problem existed in Mavericks and I thought it might be fixed in Yosemite, no such luck.
    So after disabling Folder Actions I installed Hazel, it does the same thing plus other stuff and seems to work well, it’s not cheap ($29) but at least it saves my machine crashing every so often.

    Reply
  6. xAirbusdriver

    Had most of yesterday free (advantage of being retired!), so I installed Yosemite. BAM! I got to see the ‘Dispatcher’ bug immediately. Unfortunately, all I remembered of this discussion was Mr. Singers comment about clean installs…

    Long story short, I edited the FolderActions.folder.plist and commented out four lines; two listing /System/Library/ and /Library/, and two pointing to my Library. In addition, I removed every ‘Service’ from my Library and one from /Library/ that came from Default Folder X, a rather old Pref Pane that may need updating.

    Haven’t seen the ‘Dispatcher’ crash nor its almost continuous appearance in Activity Monitor in over a couple of hours. Of course, my ‘broom’ is a little wide, but I can un-comment those lines, one at a time. OTOH, why wake up sleeping dogs! ;-)

    Reply
  7. xAirbusdriver

    After much searching, a bit of guessing, and just plain determination, I now have Folder Action Setup app behaving correctly in Yosemite (10.10.2).

    I found 15 entries in my ~/Library/Preferences/com.apple.FolderActions.plist. That looked a little excessive, especially when they all seemed to be labeled as aliases and did exactly the same thing. [rolleyes] After making a backup/duplicate of the file, I deleted absolutely every item. It then looked exactly like the version on my mini, which has been runningYosemite flawlessly, even the ßetas.

    I can now run Folder Actions Setup app without any type of crash! And that plist now indicates the settings made in the Folder Actions Setup app checkbox (checked/enabled or unchecked/disabled). Apparently, the ~/Library/LaunchAgents/com.apple.FolderActions.folders.plist now shows none of the multitude of WatchPaths that had populated the original file. I think that was part of the problem in the first place; there were so many *near*-root folders being almost constantly checked for changes that the cpu usage just rocketed, and the Folder Actions Dispatcher app eventually crashed.

    If you want to perform all the editing I did, be aware that many of these plists are the binary kind, so you won’t be able to edit them in a text editor like the XML variety. Xcode works fine and it’s also free (if quite large).

    Reply

Leave a Reply to nmt1900 Cancel reply