0

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.

  • Are they all lodging in with same credentials ? – Ruskes Mar 24 '15 at 23:07
  • "/private/var/folders") is "per-user temporary files and caches". It is created and managed by Mac OS X. The directory will be created if it does not already exist. By default, files in this location may be cleaned (removed) by the system if they are not accessed in 3 days. The cache will only be deleted with a safe boot and only files older then 3 days are cleaned out of temp. Either way, you can delete "/var/folders" and reboot whenever you would like without danger of ruining anything. – Ruskes Mar 24 '15 at 23:16
  • that would be sudo rm -rf /private/var/log/* – Ruskes Mar 25 '15 at 0:20
  • No, they are using network accounts handling by our 10.6.8 server. – Salvador Gonzalez Mar 26 '15 at 15:18
1

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*
  • After 2 months he's probably sorted the issue out by now. – paul May 19 '15 at 2:37
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

  • 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
0

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.

You must log in to answer this question.

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