[K12OSN] Deleting Swap Files

Eric Harrison eharrison at mail.mesd.k12.or.us
Fri Mar 11 23:05:01 UTC 2005


Eric Harrison wrote:
>
> There is probably a way to work-around this in any case.
> Maybe something as simple as:
>
>     for terminal in `showmount | grep -v '/'`
>     do
>         if [ -f /var/opt/ltsp/swapfiles/${terminal}.swap ]
>         then
>             touch /var/opt/ltsp/swapfiles/${terminal}.swap
>         fi
>     done
>     /usr/sbin/tmpwatch --ctime --atime --mtime 720 /var/opt/ltsp/swapfiles/
>
>
> I'm going to sleep on it before I build a test package. In the meantime,
> hopefully someone will come up with a bright idea on how to do this
> safely ;-)

After sleeping on it, chatting with Shahms King a while, and then taking
a long lunch, here is the best I can come up with:


cd /var/opt/ltsp/swapfiles/
for ip in `ls *.swap 2>/dev/null | sed s/.swap$//g`
do
    netstat -nap 2>/dev/null | grep ${ip}: >/dev/null && touch ${ip}.swap
    ping -c 1 -w 10 ${ip} &> /dev/null && touch ${ip}.swap
done
/usr/sbin/tmpwatch --ctime --atime --mtime 168 /var/opt/ltsp/swapfiles/




This would prevent a swap file from being deleted if any one of the
following were true:

   * the terminal had written to the swap file sometime in the last week
   * the terminal had a tcp connection to the server in the last week
   * the terminal could be pinged sometime in the last week


The corner-case in this scenario is fairly small. All of the following
would have to true for an active swap file to be deleted:

   * the terminal would have to be configured to use a different server
     for NFS_SWAP than it uses for its XDM connection, the default is
     that the NFS_SWAP server & the XDM server are the same.
   * pings would have to be disabled on the network
   * the terminal did not modify the swap file in the previous week


That seems sane enough for me. But then I don't use NFS_SWAP and don't
have to hear people scream when their terminals randomly crash ;-)

Any other sanity checks I could add in?

-Eric

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/k12osn/attachments/20050311/dd6a9d7d/attachment.sig>


More information about the K12OSN mailing list