Clean or clear the /tmp directory each time on shutdown in Slackware Linux

Clean or clear the /tmp directory each time on shutdown in Slackware Linux 

Create a file called rc.local_shutdown, in the /etc/rc.d/ directory and put the line below, make it executable.

#
# The Line below will be executed each time you shutdown, and clean and clear the /tmp directory.
#

/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -print0 | xargs -0r /bin/rm -fr
#
# Explanatioon of script:
#
# /usr/bin/find that command
# /tmp looks in that directory
# -1mindepth 1 to process all files except the command line arguments
# -maxdepth 1 descending one level below the command line arguments
# -print0 and printing the full file names followed by a null characters
# | then all the output is redirected
# xargs to the command building and executing commands
# -0r which looks for the arguments separated by null characters
# /bin/rm and runs the command removing files and directories
# -fr by force and recursively
#
# See: man find; man xargs; man rm
#

or

/usr/bin/find /tmp -mindepth 1 -maxdepth 1 -exec /bin/rm -rf {} +;



This script will be executed each time you'll shut down Slackware, name this file "rc.local_shutdown" and put it in the # "/etc/rc.d/" directory.

Make this file executable with:
chmod +x /etc/rc.d/rc.local_shutdown.

0 comments:

Post a Comment