Who's creating the files “/private/var/tmp/Unt

2019-06-15 07:56发布

I was investigating why a TeamCity build-agent was running out of disk, and found over 11,000 files in /private/var/tmp, all named along the lines of Untitled-<random-unique>.uicatalog.

Each file is at least 0.6MB. The total disk footprint is on the order of 4GB.

The files dated back several months, so they survived reboots.

Who is creating them?

标签: xcode7
1条回答
Anthone
2楼-- · 2019-06-15 08:32

Who is creating them?

Xcode creates these when compiling an xcassets catalog that has at least one image in it.

Can I delete them?

AFAIK, yes.

How do I delete them?

If you don't have many of them, you can delete them with rm /private/var/tmp/Untitled-*.uicatalog. If you have more than N, the wildcard on the previous command will expand to more characters than bash allows. In that case, use ls /private/var/tmp/Untitled-*.uicatalog | parallel rm.

BTW, they are owned by the user that run Xcode, which is probably you. If not, use sudo in the preceding.

How can I keep them from accumulating in the future?

As of OS X 10.11.3, the system isn't configured to clean /private/var/tmp. You can check if that's the same for you by running for P in daily weekly monthly; do sudo periodic -${P}; done and seeing if the files go away. Be aware, the periodic daily script (found at /etc/periodic/daily/110.clean-tmps) only deletes things that were created 3 or more days in the past, and ls doesn't show you create-time.

If you want to add the /private/var/tmp directory to the list of directories cleaned by periodic (see man periodic), do the following:

echo 'daily_clean_tmps_dirs="/tmp /var/tmp"' | sudo tee -a /etc/periodic.conf.local

To see it work, run sudo periodic daily. Everything in /private/var/tmp that was created 3 or more days ago will be deleted.

查看更多
登录 后发表回答