[CentOS] Deleting contents of /tmp on shutdown

Sat Dec 12 22:05:56 UTC 2009
Thomas Dukes <tdukes at sc.rr.com>

 

> -----Original Message-----
> From: centos-bounces at centos.org 
> [mailto:centos-bounces at centos.org] On Behalf Of Keith Keller
> Sent: Saturday, December 12, 2009 4:50 PM
> To: CentOS mailing list
> Subject: Re: [CentOS] Deleting contents of /tmp on shutdown
> 
> On Sat, Dec 12, 2009 at 02:33:33PM -0500, Thomas Dukes wrote:
> > I use to have a line of code in /etc/init.d/syslog (I think 
> this was 
> > the
> > file) to delete the contents of my /tmp directory on shutdown.
> 
> In /etc/init.d/syslog?  That seems like a bad place to put 
> it, even if it does check (as I assume it must have) the 
> current runlevel, and only deletes in runlevels [016] or 
> [06]; if it gets killed too early, you could delete a file 
> from /tmp that is needed to cleanly kill off a subsequent process.
> 
> /etc/init.d/halt calls /sbin/halt.local, which might be a 
> good place, except that it's already umounted nonessential 
> filesystems by then, so if you have /tmp on a different fs 
> putting it there won't work.  (You could mount it from 
> halt.local, clean it, then umount it, but that seems 
> extremely kludgy.)  You could write your own simple script 
> and link it in /etc/rc[06].d/ to run after S00killall but 
> before S01halt or S01reboot.
> (It is not clear to me whether enough processes are killed 
> off that cleaning /tmp is safe here; might be worth testing 
> in a noncritical environment
> first.)
> 
> --keith

As I said, I think that was were the code was added.  Just not really sure.
I remember the files were deleted on shutdown/reboot.

Been reading and have seen it may be better to delete the tmp directory
files on boot before any services start.  What do you think?

Thanks,

Eddie