Deleting content of /private/tmp moved on different HDD I have a Macbook pro with 2 internal HD (stock HD for data and data doubler + SSD in place of the optical drive, hosting the OS).  I'm now trying to optimize this setup to take into account the presence of the SSD, and I want to move the temporary folder from the SSD (/private/tmp) to the secondary drive (/Volume/MacintoshHD/private/tmp).

Following this (http://blog.alutam.com/2012/04/01/optimizing-macos-x-lion-for-ssd/comment-page-1/#ramdisk), here's what I did :

sudo ditto /private/tmp /Volumes/MacintoshHD/private/tmp
sudo rm -rf /private/tmp
sudo ln -s /Volumes/MacintoshHD/private/tmp /private/tmp


Everything is fine, but when I reboot, I expect the folder to be emptied as usual.  However, I found out that whatever files that were present on the previous OS execution are still present.

My guess is that whatever script emptying the /private/tmp folder executes before the magnetic HD gets mounted, which means that the link pointing to the tmp folder does not point anywhere then, and hence the failed deletion.

Any idea how to fix this?  Any other suggestion to move the /private/tmp folder to another drive and still preserve automatic deletion?
After doing some research, I ended up writing a shell script and using launchd to have it execute at boot time.

The script I use (/usr/local/bin/empty-tmp.sh) :

#!/bin/bash

# Delete files (other than directories) that haven't been modified in more than 1 day
find /Volumes/MacintosHD/private/tmp -not -type d -ctime +1d -delete

# Delete empty directores that have been created more than 1 day ago
find /Volumes/MacintoshHD/private/tmp -d -type d -empty -mindepth 1 -Btime +1d -delete


and the property list (in /Library/LaunchDeamons) :

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;com.samric.emptytmp&lt;/string&gt;

  &lt;key&gt;ProgramArguments&lt;/key&gt;
  &lt;array&gt;
    &lt;string&gt;/bin/bash&lt;/string&gt;
    &lt;string&gt;-c&lt;/string&gt;
    &lt;string&gt;/bin/wait4path /Volumes/MacintoshHD/private/tmp/ &amp;&amp; /usr/local/bin/empty-tmp.sh&lt;/string&gt;
  &lt;/array&gt;

  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;

  &lt;key&gt;LaunchOnlyOnce&lt;/key&gt;
  &lt;true/&gt;
  &lt;/dict&gt;
&lt;/plist&gt;


Now the key is using wait4path to make sure the secondary HD (MacintoshHD) is properly mounted before invoking the script.  Failing to do so will result is the script not deleting any files since they won't be accessible.