From Salix OS
Although Salix does provide /tmp cleanup during boot in /etc/rc.d/rc.S:
# Clean up some temporary files: rm -f /var/run/* /var/run/*/* /var/run/*/*/* /etc/nologin \ /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \ /var/state/saslauthd/saslauthd.pid \ /tmp/.Xauth* 1> /dev/null 2> /dev/null ( cd /var/log/setup/tmp && rm -rf * ) ( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* )
one might need to completely erase the contents of /tmp directory for some reason during restart. There might be several ways to do so, ie. scheduling the complete cleanup via crontab or mounting /tmp in memory. The easiest way however is adding some simple lines to the above rc.S script:
echo "cleaning up /tmp completely" rm -rf /tmp/* rm -rf /tmp/.??*
The first rm command deletes all non-hidden directories and files, the second removes most of the hidden ones. CAUTION: Editing system scripts should be done by advanced users who know exactly what they are doing, for example a typo in the last command (only one question mark) might lead to removal of all files in the system: rm -rf /tmp/.?* as this matches /tmp/../ which is equivalent to root directory /. Two question marks prevent this and match only files inside /tmp directory. The system scripts might change after system upgrade, too.
We might also want to wipe /var/tmp - similarly add these lines:
rm -rf /var/tmp/* rm -rf /var/tmp/.??*