Automatically clean JBoss tmp directory

JBoss_by_Red_Hat I have been poking about JBoss lately trying to get messaging working and I had a look in the %JBOSS_HOME%/server/lc_turnkey/tmp directory. As you would imagine, it was chock full of temporary files (no surprise there). What I didn’t expect was how many files! So after a quick email to Adobe Support to confirm I wasn’t going to upset anything Livecycle related, I shut down JBoss and decided to clean the files out. Sometime into the delete, I got bored and lost count at 82,000 files and something like 6GB of space!

JBoss EAP 5.1.0

I had a quick Google around and it took me to a post on the JBoss Community Forum about deleting out files on a JBoss redeploy. Another user mentions that the tmp directory is never purged on restart or starting and stopping JBoss as it was in previous versions. The recommendation was to edit the run.bat file to do this every time the server is started.

The fix

The suggestion was to delete the files before JBoss starts up in the run.bat file. This example is for JBoss on Windows, but its pretty easy to adapt for Linux (just edit the run.sh file instead)

Below is the excerpt from my C:\Adobe\Adobe LiveCycle ES4\jboss\bin\run.bat

pushd %DIRNAME%..
if "x%JBOSS_HOME%" == "x" (
  set "JBOSS_HOME=%CD%"
)
popd

rem Remove tmp folder on startup
set TMP_FOLDER=%JBOSS_HOME%\server\lc_turnkey\tmp
rmdir "%TMP_FOLDER%" /s /q

set DIRNAME=

if "%OS%" == "Windows_NT" (
  set "PROGNAME=%~nx0%"
) else (
  set "PROGNAME=run.bat"
)
Advertisements

About Darren
I am a Senior Consultant and for BizTECH Enterprise Services (Australia) specialising in AEM Forms and Adobe LiveCycle, Document Services and Adobe Experience Manager.

10 Responses to Automatically clean JBoss tmp directory

  1. jahirhussain says:

    it will delete only server while restarting, but please tell me is there configuration to set time to delete the temp files

    • Darren says:

      I am not sure you would want to do this while JBoss is running as some application might be temporarily using the temp area to store application data. I only do it on restart as I know they aren’t in use anymore.

  2. Kristian says:

    Nice post. Been digging around on what’s eating into my hard drive today – 50GB of files in my tmp directory! Thanks for the info on not just deleting them, but how to update the startup script to prevent this from happening again.

  3. Siraj says:

    Hi Darren,

    Thanks for the post. This fix is perfectly working when jboss is run as a standalone program. I have a requirement where i am running jboss as a service (windows service). We are installing the service using “Java Service Wrapper”. Is it possible to apply the same fix while running as a service?

    Thanks,
    Siraj

  4. Siraj says:

    Hi Darren,

    The “Java Service wrapper” internally calls the run.jar and it looks like it is not referring the run.bat file.

    Siraj

    • Darren says:

      Siraj – if you read \Adobe LiveCycle ES4\jboss\bin\README-service.txt it says “The service executable jbosssvc.exe transforms the run.bat and shutdown.bat batch scripts to services. This means that any change made to those scripts will be used both in service and command line mode.”

      I expect if you make any changes to the run.bat and want to run JBoss as a service, you need to uninstall and reinstall the service installation for windows. The instructions are listed in that file.

  5. Cosmin says:

    Hey, thanks for sharing. This solution is working indeed but only when stoping/starting the JBoss explicitly. I fixed it like this both for Win/Linux, but this is not enough. I do not manage to find a solution for cases when only redeploying application with JBoss started. So you have the Jboss running, you delete the files from deployments, the un-deploy is performed and afterwards you copy the new wars and the deploy is performed with new version, but the temp folder size is still increasing cause other temporary folders are created in there. Any suggestions for this scenario ? I am using JBoss EAP 6.2 (I know the problem should be solved in this version according to them, but seems it is not).

    • Darren says:

      I’m not actually sure what to do in this scenario. My issues were only with my development instance so restarting was never a problem. Maybe ask the JBoss people on their forums?

  6. Rupert Everett says:

    Is the “work” directory removed at server restart? Or it need a configuration customization as in this case?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

aemblog

Everything AEM aka CQ5 based on my experience listed here.

Adobe AEM The Right Way

Best practices, tips, and tricks for your Adobe AEM project

/home/bkondepudi

A WCM journey with Day/Adobe CQ

Technoracle (a.k.a. "Duane's World")

A multi-purpose toolkit for the Adobe LiveCycle and AEM Forms developer.

Adobe LiveCycle Blog

A multi-purpose toolkit for the Adobe LiveCycle and AEM Forms developer.

A multi-purpose toolkit for the Adobe LiveCycle and AEM Forms developer.

XFA@Mobile

A multi-purpose toolkit for the Adobe LiveCycle and AEM Forms developer.

Code Monkey

Ramblings of a Developer

%d bloggers like this: