"Too many open files" error due to monitoring scripts


AEM is occassionally crashing with the error "Too many open files".


First follow the steps in this article to see if your maximum open file limit is set too low.

If your ulimit -n is at least 8192 then it might be that you are experiencing a known issue where the monitoring scripts in AEM are causing your system to crash due to a file handle leak.

If you are observing the errors below in the logs, then follow the steps below:

14.03.2016 02:50:13.498 *ERROR* [Process Executor for diskusage.sh] com.adobe.granite.monitoring.impl.ShellScriptExecutorImpl Error while executing script /opt/publish/crx-quickstart/monitoring/diskusage.sh
java.io.IOException: Cannot run program "/opt/publish/crx-quickstart/monitoring/diskusage.sh" (in directory "/opt/publish/crx-quickstart/monitoring"): error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at java.lang.Runtime.exec(Runtime.java:620)
        at com.adobe.granite.monitoring.impl.ShellScriptExecutorImpl$ProcessExecutor.run(ShellScript ExecutorImpl.java:307)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
        at java.lang.ProcessImpl.start(ProcessImpl.java:134)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 3 common frames omitted
14.03.2016 02:50:13.500 *ERROR* [Shell Script Executor Thread for cpu.sh] com.adobe.granite.monitoring.impl.ShellScriptExecutorImpl Unable to extract script 'cpu.sh' to '/opt/publish/crx-quickstart/monitoring/cpu.sh'
java.io.FileNotFoundException: cpu.sh
        at com.adobe.granite.monitoring.impl.ShellScriptExecutorImpl.extractScript(ShellScriptExecut orImpl.java:177)
        at com.adobe.granite.monitoring.impl.ShellScriptExecutorImpl.execute(ShellScriptExecutorImpl .java:112)
        at com.adobe.granite.monitoring.impl.ScriptMBean.invoke(ScriptMBean.java:99)
        at com.adobe.granite.monitoring.impl.ScriptMBean.invoke(ScriptMBean.java:158)
        at com.adobe.granite.monitoring.impl.ScriptConfigImpl$ExecutionThread.run(ScriptConfigImpl.j ava:209)
        at java.lang.Thread.run(Thread.java:745)

The monitoring scripts are additional Threads in CQ (labeled "Shell Script Executor Thread for ....") that are started/stopped by the presence of factory configurations for the "Adobe Granite Monitor Handler" component.
There are 2 configurations defined out-of-the-box (cpu.sh and diskusage.sh scripts).

To resolve this issue, the configurations can be deleted:

AEM 6.x:

1. Log in as the admin user

2. Go to http://host:port/system/console/configMgr

3. Search for com.adobe.granite.monitoring.impl.ScriptConfigImpl, there are two default configuration nodes under Adobe Granite Monitor Handler

4. Delete those two configurations

CQ5.x - CQ5.6.1:

Either install the attached package, or do the following:

  1. Log into http://localhost:4502/crxde as admin user.
  2. Browse to /libs/granite/monitoring/config
  3. Right click and delete each subnode of /libs/granite/monitoring/config
  4. Click "Save All"
  5. Restart CQ

This should remove the configurations, and consequently stop the Monitoring Threads.


If the configurations were modified via the Felix Console then the configurations would be persisted on the file system.  In that case, deleting the sling:OsgiConfig nodes as describe before is not enough to remove the configuration.
Open the Felix Console (http://host:port/system/console/configMgr), and delete the factory configurations under "Adobe Granite Monitor Handler".


Applies to

CQ5.5 and later, AEM 6.x