Slackware-13.1-Hacks-Emptying tmp
Posted 01-01-2011 at 10:09 PM by arniekat
# This will empty the /tmp folder when you shutdown or
# reboot the machine
# Add this line to /etc/rc.d/rc.6
echo "Emptying /tmp"
rm /tmp/* -rf &1>2 > /dev/null
The /dev/null part gets rid of any output/error codes.
I placed it between the following sections in /etc/rc.d/rc.6
# Save the system time to the hardware clock using hwclock --systohc.
if [ -x /sbin/hwclock ]; then
# Check for a broken motherboard RTC clock (where ioports for rtc are
# unknown) to prevent hwclock causing a hang:
if ! grep -q -w rtc /proc/ioports ; then
CLOCK_OPT="--directisa"
fi
if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
echo "Saving system time to the hardware clock (UTC)."
/sbin/hwclock $CLOCK_OPT --utc --systohc
else
echo "Saving system time to the hardware clock (localtime)."
/sbin/hwclock $CLOCK_OPT --localtime --systohc
fi
fi
# Clean out the /tmp directory
echo "Emptying /tmp"
rm /tmp/* -rf &1>2 > /dev/null
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
/etc/rc.d/rc.local_shutdown stop
fi
# reboot the machine
# Add this line to /etc/rc.d/rc.6
echo "Emptying /tmp"
rm /tmp/* -rf &1>2 > /dev/null
The /dev/null part gets rid of any output/error codes.
I placed it between the following sections in /etc/rc.d/rc.6
# Save the system time to the hardware clock using hwclock --systohc.
if [ -x /sbin/hwclock ]; then
# Check for a broken motherboard RTC clock (where ioports for rtc are
# unknown) to prevent hwclock causing a hang:
if ! grep -q -w rtc /proc/ioports ; then
CLOCK_OPT="--directisa"
fi
if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
echo "Saving system time to the hardware clock (UTC)."
/sbin/hwclock $CLOCK_OPT --utc --systohc
else
echo "Saving system time to the hardware clock (localtime)."
/sbin/hwclock $CLOCK_OPT --localtime --systohc
fi
fi
# Clean out the /tmp directory
echo "Emptying /tmp"
rm /tmp/* -rf &1>2 > /dev/null
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
/etc/rc.d/rc.local_shutdown stop
fi
Total Comments 1
Comments
-
If you have enough ram, it's equally effective to have a ram filesystem mounted to /tmp.
Posted 01-01-2011 at 10:53 PM by lumak