LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-14-2006, 05:34 AM   #1
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Rep: Reputation: 20
command last


Hello,

I want to display logins after a especific date. The -t switch of the last command gives me the opposite, i.e, it gives the logins till that date. Any idea how I can approach this?

Thanks.
 
Old 07-14-2006, 07:05 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
I think you need a script to filter the dates that are greater than the data you specify. I can't see any cmd-line trick to do that.

The best language to do this is perl. It has functions to handle dates and times, so you can compare dates easily.
 
Old 07-14-2006, 10:17 AM   #3
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Original Poster
Rep: Reputation: 20
Now I have a problem... the last command doesn't show the year.

Note: I will call to the Linux command last as last()

I am checking the remote root logins and keeping the last occurrence in a file. When I want to check for new occurrences I run last() filtered with root and non-local address and compare the date with the last occurence in the file. I am comparing month, day and time but if the last() gives me occurrences from the past year, I will go into trouble... .
I think that wtmp is "logrotating" (I don't now if it is by time or size) so I hope it will not contain entries from the past year.

Any ideas or thoughts about this?

Thanks.
 
Old 07-14-2006, 04:44 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by bujecas
I think that wtmp is "logrotating" (I don't now if it is by time or size) so I hope it will not contain entries from the past year.

Any ideas or thoughts about this?

Thanks.
Depends on the distro, in slack it's once a month.
You could check your /etc/cron.* directories, /etc/crontab (if
it exists) and for root crontab -l ...


Cheers,
Tink
 
Old 07-14-2006, 05:42 PM   #5
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
"last -F" should display the year.
That is it does here.

(Did you notice the rhyme? Is there a subforum for advanced poetry?)

You could probably extract the date from last and convert it to seconds since epoch using the "date" command. Then retrieving the logins that occured since a specified date will reduce to a simple numerical comparison.
 
Old 07-17-2006, 04:10 AM   #6
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by spirit receiver
"last -F" should display the year.
For instance, in my Debian Sarge the -F switch doesn't exist...
 
Old 07-18-2006, 03:32 PM   #7
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
What a shame. Then this might be of interest: http://www.itworld.com/Comp/1375/nls...331/index.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Why after start of a command the invitation for input next command has not appeared. ukrainet Linux - General 3 06-24-2005 08:16 AM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 07:14 PM
Command to display whole filestructure hierarchy f/ command line? mjewell Linux - Newbie 10 01-19-2004 10:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration