Posted on 09-26-2014 08:32 AM
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.
Solved! Go to Solution.
Posted on 09-26-2014 08:47 AM
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.
Posted on 09-26-2014 08:43 AM
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.
Posted on 09-26-2014 08:47 AM
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.