LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2013, 07:46 AM   #1
bravored
Member
 
Registered: Mar 2005
Distribution: RHEL, freeBSD, Solaris
Posts: 49

Rep: Reputation: 0
Prase and report user login for today's date


All,

I want to get a count current user logon count for the day/date

The access.log doesnt rotate per day..

At the moment I get it by: cat access.log| grep 2013-09-13| grep Succeeded| wc -l

So for tomorrow I would have to change the date to 2013-09-14.

Any ideas?

Thanks,
 
Old 09-13-2013, 08:44 AM   #2
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
have you tried it with the date command? The manpage helps you to get the format right.
 
Old 09-13-2013, 08:57 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://www.linuxquestions.org/questi...-and-tar-41754
shows examples that you can work with.
 
Old 09-13-2013, 10:31 AM   #4
bravored
Member
 
Registered: Mar 2005
Distribution: RHEL, freeBSD, Solaris
Posts: 49

Original Poster
Rep: Reputation: 0
Yea I tried the date command; I get syntax error

cat logon.list | grep 2013-09-11| |grep Succeeded | wc -l

OK I tried it again, and it went through.

Ended up using date=`date '+%Y-%m-%d'` as the variable
 
Old 09-13-2013, 12:56 PM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by bravored View Post
Yea I tried the date command; I get syntax error

cat logon.list | grep 2013-09-11| |grep Succeeded | wc -l

OK I tried it again, and it went through.

Ended up using date=`date '+%Y-%m-%d'` as the variable
Don't cat, just to grep. Try
Code:
grep $(date +"%Y-%m-%d") logon.list | grep Succeeded | wc -l
Other more experienced people may have other ideas as well.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] IF Statement that compares today's date with a date entered Icewolf0927 Programming 4 08-13-2011 10:21 PM
User login expiry date? geekgrl Linux - Security 7 07-04-2011 06:08 AM
[SOLVED] Last login all user details with last login date needed gadhave.vikas Other *NIX 3 06-10-2011 01:50 PM
A script that will display only the last login of each user with the date and year? mrotsliah Linux - General 4 04-21-2010 03:42 AM
sarg - generating report via date - date mandrakeBren Linux - Newbie 0 10-29-2009 07:31 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:42 PM.

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