SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
well i'm not familiar with slackware really, but i'd suggest a more elegnat solution like using a tmpfs filesystem as /tmp. this will hold all data in memory / swap partition and so won't persist across a boot anyway. just a line in your fstab file like
tmpfs /tmp tmpfs defaults 0 0
in actual fact though, you may well already have a similar line to /dev/shm or such like, ready to do the same job... could just use a symlink to it if you have one (redhat based systems do...)
if you do wish to just delete files, i'd recommend clearing it on startup, not shutdown though, just as simple but with less chance of busting a runlevel.
since version 11 you can write a rc.local_shutdown file.
Quote:
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
DON'T clear everthing in /tmp from a script in /etc/rc.d/rc.local. You might trash the hidden directories required by X that are checked for, and created in /etc/rc.d/rc.S.
MQMan is right. The best place to put the housekeeping script is either /etc/rc.d/rc.local_shutdown as erklaerbaer has pointed out or in during the startup or better still to mount tmpfs on /tmp as pointed out by acid_kewpie.
I use tmpfs but there's also something called bootclean
/etc/init.d/bootclean
that removes old files but not some exceptions.
I post it here because I'm not sure all distro have it:
mkflagfile()
{
# Prevent symlink attack (See #264234.)
[ -L "$1" ] && log_warning_msg "bootclean: Deleting symbolic link '$1'."
rm -f "$1" || { log_failure_msg "bootclean: Failure deleting '$1'." ; return 1 ; }
# No user processes should be running, so no one should be able to introduce
# a symlink here. As an extra precaution, set noclobber.
set -o noclobber
:> "$1" || { log_failure_msg "bootclean: Failure creating '$1'." ; return 1 ; }
return 0
}
clean_tmp() {
cd /tmp || { log_failure_msg "bootclean: Could not cd to /tmp." ; return 1 ; }
#
# Only clean out /tmp if it is world-writable. This ensures
# it really is a/the temp directory we're cleaning.
#
[ "$(find . -maxdepth 0 -perm -002)" = "." ] || return 0
if [ ! "$TMPTIME" ]
then
log_warning_msg "Using default TMPTIME 0."
TMPTIME=0
fi
[ "$VERBOSE" = no ] || log_action_begin_msg "Cleaning /tmp"
#
# Don't clean remaining files if TMPTIME is negative or 'infinite'
#
case "$TMPTIME" in
-*|infinite|infinity)
[ "$VERBOSE" = no ] || log_action_end_msg 0 "skipped"
return 0
;;
esac
# Wipe /tmp, excluding system files, but including lost+found
#
# If TMPTIME is set to 0, we do not use any ctime expression
# at all, so we can also delete files with timestamps
# in the future!
#
if [ "$TMPTIME" = 0 ]
then
TEXPR=""
DEXPR=""
else
TEXPR="-mtime +$TMPTIME -ctime +$TMPTIME -atime +$TMPTIME"
DEXPR="-mtime +$TMPTIME -ctime +$TMPTIME"
fi
report_err()
{
if [ "$VERBOSE" = no ]
then
log_failure_msg "bootclean: Failure cleaning /tmp."
else
log_action_end_msg 1 "bootclean: Failure cleaning /tmp"
fi
}
#
# First remove all old files...
# (Use xargs here so that only one additional process gets created)
#
find . -depth -xdev $TEXPR $EXCEPT ! -type d \
-print0 | xargs -0r rm -f -- \
|| { report_err ; return 1 ; }
#
# ...and then all empty directories
# (Don't use xargs here because dirs must be removed one by one from
# the bottom up)
#
find . -depth -xdev $DEXPR $EXCEPT -type d -empty \
-exec rmdir \{\} \; \
|| { report_err ; return 1 ; }
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.