1

We have fleets of laptops that have limited space once our software is installed on it. What ever the issue that is causing the creation of theses files and --err not flushing them, we are ignoring for the moment. But I would like to automatically delete the contents /private/var/folders/. We have maybe 5-10 students log in to a laptop a day. Not sure if that will be an overkill. Any help would be appreciated.

2

It's a simple way. You can use the getconf DARWIN_USER_CACHE_DIR command to get the per-user temporary files and caches directory. and remove it. edit the '/etc/profile' file, add the following codes in it(not test yet):

userTempDir=`/usr/bin/getconf DARWIN_USER_CACHE_DIR`
rm -fr $userTempDir*
1

This is probably sorted out by now, but for future readers:

do shell script "rm /private/var/folders/"

error that says: error "rm: /private/var/folders/ : is a directory"

You need rm -r to remove a directory and it's contents. However, I would suggest that if you don't already know that detail, then perhaps destructive shell commands are not for you.

For example:

rm -r /private/var/folders/*

rm -r /private/var/folders /*

One erases temporary cache folders, the other erases the entire drive. Can you see why?

Deleting /private/var/folders/ won't solve your space problem. Cached files are there for system performance. If you erase them the system will just refill the directory. If you are so short of space that 1.5Gb makes a difference you need to take a critical look at either your installed software or your drive size.

0

You could try (for free) this app https://www.peterborgapps.com/lingon/

Run what you want, whenever you want

Lingon can start an app, a script or run a command automatically whenever you want it to. You can schedule it to run at a specific time, regularly or when something special happens.

Or you could write your own script that contains the sudo rm -rf /private/var/log/* command

  • 1
    the sudo script does not work for me. I am getting somewhere with -- set myPath to "/private/var/folders/" set usr to "username" set psd to "password" do shell script "rm " & quoted form of myPath user name usr password psd with administrator. But I get an error that says: error "rm: /private/var/folders/ : is a directory" number 1. If i remove the last "/" will OS X replace the "folders" directory? – Salvador Gonzalez Mar 26 '15 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .