Difference between revisions of "How to completely erase /tmp"
m |
m (clarifying) |
||
Line 9: | Line 9: | ||
( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* ) | ( 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. There might be several ways to do so, | + | one might need to completely erase the contents of /tmp directory for some reason. There might be several ways to do so, ie. scheduling the complete cleanup via crontab. The easiest way however is adding some simple lines to the above '''rc.S''' script: |
echo "cleaning up /tmp completely" | echo "cleaning up /tmp completely" |
Revision as of 22:58, 30 November 2010
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. There might be several ways to do so, ie. scheduling the complete cleanup via crontab. 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: 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.
We might also want to wipe /var/tmp - similarly add these lines:
rm -rf /var/tmp/* rm -rf /var/tmp/.??*