- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: finding date in wtmp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 11:31 AM
09-26-2002 11:31 AM
e.g. excerpt from line in wtmp ... Jun 6
Note, the extra space between month and 6. When I calculate a date, I can't get the extra space in there. Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 11:37 AM
09-26-2002 11:37 AM
Re: finding date in wtmp
How do you want to calculate the date and how do you want to search?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 11:47 AM
09-26-2002 11:47 AM
Re: finding date in wtmp
Try this way
DAY=$(date +%d)
MONTH=$(date +%b)
DATE=$(printf "%s %2.3s" $MONTH $DAY)
last -R |grep "$DATE"
The above is only example. You can use that logic in your script.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 11:49 AM
09-26-2002 11:49 AM
Re: finding date in wtmp
Here's what I want to do. I want to keep the last 90 days of data in my wtmp, deleting the rest. I have calculated 90 days prior to today. My next step was going to be determining the line number matching my calc'd date and delete all previous lines. Something along these lines ...
X=grep -n "Jun 6" wtmp.tmp | head -1 | cut -d : -f 1
sed '1,Xd' wtmp.tmp > wtmp.clean
I know that isn't all correct, but I'm new to this scripting thing (coming from Win env) and I haven't worked out all the details. Any help would be greatly appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 12:03 PM
09-26-2002 12:03 PM
Re: finding date in wtmp
Your approach is fine. Do this:
X='Jun 6' #...there are really 2-blanks here...
# sed -e "1,/$X/"d filein
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 01:14 PM
09-26-2002 01:14 PM
Re: finding date in wtmp
I'm now thinking that I may have to awk out the month and day from the appropriate columns of the wtmp.tmp file and then match on both.
WDYT?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 01:22 PM
09-26-2002 01:22 PM
SolutionIf you look at the value of $DATE, it will have two spaces for a single digit date and one space for double digit date from the month's field.
If you already calculated the date, it is easy to create an extra space between the month and the day using printf statement but you have to first devide the date into day and month as I did in the example.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 01:26 PM
09-26-2002 01:26 PM
Re: finding date in wtmp
If you folllow Sri's use of 'printf' you can construct the "$X" argument to the 'sed' I suggested.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2002 01:27 PM
09-26-2002 01:27 PM
Re: finding date in wtmp
typeset -R2 daynum=6
Then when you use $daynum in your script it will have the extra space.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2002 04:33 AM
09-27-2002 04:33 AM
Re: finding date in wtmp
Dalin