- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Last command does not show year in HP-UX
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
Discussions
Discussions
Forums
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
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
тАО08-27-2007 04:28 PM
тАО08-27-2007 04:28 PM
Last command does not show year in HP-UX
Please let me know if their is any script to generate the year with last command.
$ last oracle|more
oracle pts/1 Mon Aug 27 15:49 - 17:55 (02:06)
For solaris we have as
last | nawk 'BEGIN {y='`date +%Y`'}$5 == "Dec" && last != "Dec" { y-- }{ print y,$0 ; last = $5 }' |more
But nawk does not work in HP.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 04:47 PM
тАО08-27-2007 04:47 PM
Re: Last command does not show year in HP-UX
Please read the thread below.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1143386
Regards,
Asif Sharif
Asif Sharif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 05:07 PM
тАО08-27-2007 05:07 PM
Re: Last command does not show year in HP-UX
last command will not display year. But you can use fwtmp to extract out the year.
To read the contents of the wtmp file, cat the file to fwtmp, as follows:
#cat /var/adm/wtmp | /usr/sbin/acct/fwtmp
WK
please assign points
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2007 06:27 PM
тАО08-27-2007 06:27 PM
Re: Last command does not show year in HP-UX
You let users remain logged on the system constantly from year to year?
As the thread shows, the information certainly does exist, however the reason HP didn't include it may be the basic assumption that everybody knows what year it is.
Even 24/7 systems should be brought down twice a year for critical bi-annual and security patches, making the need to display the year, somewhat superflous?
Good Luck,
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2007 06:09 AM
тАО08-28-2007 06:09 AM
Re: Last command does not show year in HP-UX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2007 06:34 AM
тАО08-28-2007 06:34 AM
Re: Last command does not show year in HP-UX
Ah, I didn't look at the script. I thought of writing something like this for the other thread but using fwtmp seemed better.
Your awk script has several flaws. You need to look at $4 and sometimes $5 (if you rebooted in Dec). Also `` doesn't work within '', so you need to use -v:
last | awk -v y=$(date +%Y) '
{
if ($2 == "system" && $3 == "boot") month = $5
else month = $4
if (month == "Dec" && last != "Dec") y--
print y,$0
last = month
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2007 06:50 PM
тАО08-28-2007 06:50 PM
Re: Last command does not show year in HP-UX
besides the correct approach to use 'fwtmp', I see no problem in this awk-statement regarding backticks:
awk 'BEGIN {y='`date +%Y`'} ...'
Having spliced in the `..` into two parts of single quoted strings AND `date +%Y` not producing any spaces in output, the finally string the shell leaves as commands for the awk is only one argument and so perfectly OK.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2007 12:04 PM
тАО08-29-2007 12:04 PM
Re: Last command does not show year in HP-UX
Ah, you are correct but nobody in their right mind should use that. The whole awk script should be single quoted, not pieced together like Humpty-Dumpty. Also, this wouldn't work for awk -f.
Here is another thread about awk -v:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1131538
And here is where I explain your trick:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1105084
Bill:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1049976
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=810890
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=324808