Operating System - HP-UX
1829889 Members
2469 Online
109993 Solutions
New Discussion

how to count the days of inactivity for every account?

 
hdx
New Member

how to count the days of inactivity for every account?

hi

my boss gave me a tough job to see the number of days since the last login to now.
my system is HPUX 11.0 and NIS is used.

any idea ar ewelcomed.

5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: how to count the days of inactivity for every account?

Hi:

Last login activity (by user) is logged in '/var/adm/wtmp', otherwise known as the 'last" database because the standard command to view activity is 'last'. The file is a binary file.

If you don't have the file, logging is disabled. If this is the case, as root, do:

# touch /var/adm/wtmp

The file will grow infinitely, so usually it is emptied by redirecting /dev/null to it.

# last

# last -R

...will show the last time logged into the server.

See the manpages for 'last' for more information.

Regards!

...JRF...
hdx
New Member

Re: how to count the days of inactivity for every account?

My boss hoped a script to run as a cron to see the number days from last login in a simple report.

The output of last is too tough for him. he never come to the unix

Steven E. Protter
Exalted Contributor

Re: how to count the days of inactivity for every account?

Shalom hdx

passwd -sa

produces a report that might be helpful. On NIS, this must be run on the NIS Master, or should be.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: how to count the days of inactivity for every account?

Hi (again):

Too touch for your boss...OK, here's two other suggestions:

Suggestion-1:

# finger

...will produce a simply query and result, including text like, "Last login Tue Dec 13 23:17 on ttyp1". Teach the boss to use it (or maybe not).

Suggestion-2:

Write a shell script to produce what you need. The 'wtmp' file is a binary file that can be converted to ASCII records:

# /usr/sbin/acct/fwtmp < /var/adm/wtmp

You can pick out the most recent login for any account by looking for the largest value of that login's 7th field (zero-relative). It is the epoch time --- the number of seconds since January 1, 1970. It will correspond to the localtime you see in the 8-11-th fields following it.

Regards!

...JRF...
Bob Ingersoll
Valued Contributor

Re: how to count the days of inactivity for every account?

If your system is trusted you can use getprpw to display the last successful login time:

/usr/lbin/getprpw -m slogint