[Gllug] Run script on last logout

Alain Williams addw at phcomp.co.uk
Wed Jul 18 09:28:15 UTC 2007


On Wed, Jul 18, 2007 at 09:16:21AM +0100, Henrik Bilar wrote:
> 
> Not sure if it would work, but perhaps something like this:
> 
> if [[ `w | grep $USER | wc -l ` -eq 1 ]]; then echo 'yes' ; else echo 'no'
> ; fi

Errrm, no. If your login is 'fred' that will also see/count 'freddy' & 'alfred'.

This is better:

	(( $( who | grep -c "^$USER " ) > 1 )) && echo yes || echo no

> 
> > Hi,
> >
> > I would like to run a command/script from my .bash_logout file but only
> > when exiting the last login to the machine (by that user).  Can anyone
> > suggest a way of detecting the last logout (or an alternative from using
> > .bash_logout)?

-- 
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list