Protection from "rm *"

John Macdonald jmm at eci386.uucp
Fri Oct 19 01:29:58 AEST 1990


In article <1990Oct16.215634.23052 at athena.mit.edu> jik at athena.mit.edu (Jonathan I. Kamens) writes:
|In article <4198 at lib.tmc.edu>, jmaynard at thesis1.hsch.utexas.edu (Jay Maynard) writes:
||> OK...I give up. Why is not being able to remove a program in use a botch?
|
|  [... description of why ...]              There is no reason not to be able
|to delete a file which is an executable image currently in use.  There *are*
|reasons why you *should* be able to do so.  [...]
|
|  If I can't delete a running executable, I am left with two choices: (a) move
|the file to a different name (e.g. "foo.old") and copy the new one into place,
|or (b) copy the new binary on top of the old one.  The former choice is less
|than optimal because I have to remember to go back and delete the ".old" file
|later (and who knows, somebody may keep it running it all night, or for
|several days, or whatever!), and the second choice is less than optimal
|because after the new binary is copied on top of the old one, people will get
|swap errors when the kernel tries to swap in from the (nonexistent) old
|executable image.

If this is a frequently occurring activity, then there is a simple way of
getting choice (a) to work correctly.  Make a directory "old" in each bin
directory.  To destructively update foo, "mv foo old/rm$$", and then copy
in the new version.  Have a cron job that runs nightly that does
"find /bin/old /usr/bin/old <any others> -type f -print | xargs rm -f".
It will keep trying until it can actually do the job.  In times of heavy
program upgrades, the cron job could be tried hourly if the old versions
are cluttering up the disk.  Alternately, the script that does moves old
stuff to the old directory could get fancy - remove if possible before
moving to old, and try to clean out the old directory too in case something
is now removable.
-- 
Cure the common code...                      | John Macdonald
...Ban Basic      - Christine Linge          |   jmm at eci386



More information about the Comp.unix.misc mailing list