[CentOS] Deleting contents of /tmp on shutdown

Sat Dec 12 21:49:51 UTC 2009
Keith Keller <kkeller at speakeasy.net>

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


-- 
kkeller at speakeasy.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20091212/33ada183/attachment-0005.sig>