Skip to main content
Solved

EA for Folder Size /private/var/folders

  • September 26, 2014
  • 2 replies
  • 22 views

Forum|alt.badge.img+3

Hello All,

Long time lurker...first time poster.

Does anyone have a good EA script for finding/reporting a folder size? I'm dealing with a similar issues found here:

https://jamfnation.jamfsoftware.com/discussion.html?id=10555

On our lab machines, the /private/var/folders is getting to be a problem for us. The thread had a great direction, but i'm looking for an EA that people have had success using.

Best answer by mm2270

Are you just looking for a simple human readable output of the total size of "/private/var/folders/"? If so, while not actually using this, something like would do it. It should output a human readable size in B, K, M, or G notation, meaning from bytes up to gigabytes.

#!/bin/sh

echo <result>$(du -hs /private/var/folders | awk '{print $1}')</result>"

If on the other hand, you want to get something in a straight integer format that can later be used with a greater than less than type Smart Group, you could use this instead-

#!/bin/sh

echo "<result>$(($(du -hsk /private/var/folders | awk '{print $1}')/1024))</result>"

That would always produce a result in MB size, but if it happens to be lower than 1 MB would result in "0", or if higher than 1 GB would produce something in the range of "1000" and up.

2 replies

davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • September 26, 2014

Not sure if this is what you are looking for but I hope it helps:

#!/bin/sh
result=du -h -d 0 /private/var/folders
echo "<result>$result</result>"

You could drop the -h to get a numerical value back that you can scope smart groups to using less than / more than etc.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • Answer
  • September 26, 2014

Are you just looking for a simple human readable output of the total size of "/private/var/folders/"? If so, while not actually using this, something like would do it. It should output a human readable size in B, K, M, or G notation, meaning from bytes up to gigabytes.

#!/bin/sh

echo <result>$(du -hs /private/var/folders | awk '{print $1}')</result>"

If on the other hand, you want to get something in a straight integer format that can later be used with a greater than less than type Smart Group, you could use this instead-

#!/bin/sh

echo "<result>$(($(du -hsk /private/var/folders | awk '{print $1}')/1024))</result>"

That would always produce a result in MB size, but if it happens to be lower than 1 MB would result in "0", or if higher than 1 GB would produce something in the range of "1000" and up.