home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!convex!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: How to determine user login time in minutes?
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Aug26.201250.12162@news.eng.convex.com>
- Date: Wed, 26 Aug 1992 20:12:50 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <cosmo.714854795@cherry>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- Keywords: time, login, accounting
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 26
-
- From the keyboard of cosmo@cherry.ucsb.edu (Burtin;Boris;;;;COMS;Undergraduate;940630;911002;1000):
- :I'd like to keep track of how long I've used the system. This should be done
- :in my .logout file. I've played around with "last," but it won't give me the
- :time for the _current_ session (it says "still logged in").
- :
- :Is there a utility that I'm missing? Or does someone know of a script
- :(preferably in Perl) that will figure out the login time?
-
- If you have Cnews installed on your system, you can do this:
-
- #!/usr/bin/perl
- $GETDATE = '/usr/local/lib/news/newsbin/getdate';
- ($logtime) = `who am i` =~ /(\w{3}\s+\d+\s+\d+:\d+)/;
- printf "%.2f minutes\n", (time - `$GETDATE "$logtime"`)/60;
-
- If you don't have C news, you can do a lot of other things,
- like you the getdate.pl produced from getdate.y by the perlian
- byacc, or you can look at ttys and utmp to figure it out.
- But this seems easiest to me.
-
- --tom
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
- "The number of UNIX installations has grown to 10, with more expected."
- - _The UNIX Programmer's Manual_, Second Edition, June, 1972.
-