last 90 days????

last 90 days????

Post by singpg » Thu, 27 Sep 2001 18:41:42



Hello,

I need to write a script for user management . I want to display the
users who were not logged in system for the past 90days. I wrote some
scripts using the last <username>(with options also) command but in
the last command it's not giving the year to calculate correctly, so
am failed in the job.

For ex.


(00:02)

i dont know whether the above line for year 2000 or 2001.
Pl. provide ur valuable suggestion/recommendation.Let me know if we
have any tools for this.

And i have one more Query?

I want to lock the users when he tried 6 bad attempts . I did this
task in SCO , but in solaris i dont know how to do that. Provide
solution for this also.

For both my req. the OS is Solaris 7 & 8.

Thanks to spend ur time.
Regards

 
 
 

last 90 days????

Post by Martin Jos » Thu, 27 Sep 2001 21:11:48



> Hello,

> I need to write a script for user management . I want to display the
> users who were not logged in system for the past 90days. I wrote some
> scripts using the last <username>(with options also) command but in
> the last command it's not giving the year to calculate correctly, so
> am failed in the job.

> For ex.


> (00:02)

> i dont know whether the above line for year 2000 or 2001.
> Pl. provide ur valuable suggestion/recommendation.Let me know if we
> have any tools for this.

I would guess that the time-info is stored (as usual) as seconds since
epoch.
(On HPUX this is the case)
So I would further guess, that the year shows up, if it is not the
current year (or
the date is more than one year in the past)
Have you checked ?!
If all else fails, you will have to read the relevant file yourself.

Quote:> I want to lock the users when he tried 6 bad attempts . I did this
> task in SCO , but in solaris i dont know how to do that. Provide
> solution for this also.

> For both my req. the OS is Solaris 7 & 8.

What about using the output of last and lastb ?

HTH

Martin

 
 
 

last 90 days????

Post by Chris F.A. Johnso » Fri, 28 Sep 2001 03:49:07




> > Hello,

> > I need to write a script for user management . I want to display the
> > users who were not logged in system for the past 90days. I wrote some
> > scripts using the last <username>(with options also) command but in
> > the last command it's not giving the year to calculate correctly, so
> > am failed in the job.

> > For ex.


> > (00:02)

> > i dont know whether the above line for year 2000 or 2001.
> > Pl. provide ur valuable suggestion/recommendation.Let me know if we
> > have any tools for this.

> I would guess that the time-info is stored (as usual) as seconds since
> epoch.
> (On HPUX this is the case)
> So I would further guess, that the year shows up, if it is not the
> current year (or
> the date is more than one year in the past)
> Have you checked ?!

The year doesn't show up with any version of "last" that I've seen.

The /var/log/wtmp files, where "last" gets its data, are typically rotated
periodically, the period depending on system usage. The final line output
by last, gives the date the file was created and may contain the year.

I've fixed the year in shell scripts by decreasing the year number when
the month switches to an earlier month (awk's associative arrays are
good for this).

Quote:> If all else fails, you will have to read the relevant file yourself.

The standard format of the wtmp file is (from /usr/include/utmp.h):

struct utmp {
        char    ut_line[UT_LINESIZE];
        char    ut_name[UT_NAMESIZE];
        char    ut_host[UT_HOSTSIZE];
        time_t  ut_time;

Quote:};

It wouldn't be hard to read the it in C.

Quote:> What about using the output of last and lastb ?

I've never seen a command "lastb".

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2001, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

last 90 days????

Post by Martin Jos » Fri, 28 Sep 2001 20:57:46



> > If all else fails, you will have to read the relevant file yourself.

> The standard format of the wtmp file is (from /usr/include/utmp.h):

> struct utmp {
>         char    ut_line[UT_LINESIZE];
>         char    ut_name[UT_NAMESIZE];
>         char    ut_host[UT_HOSTSIZE];
>         time_t  ut_time;
> };

> It wouldn't be hard to read the it in C.

You can even do ti with perl (I did)
But on HPUX there are more fields (IIRC)

Quote:> > What about using the output of last and lastb ?

> I've never seen a command "lastb".

Then have a look at HPUX (10.20) :-)
 last(1)                                                            
last(1)

 NAME
      last, lastb - indicate last logins of users and ttys

 SYNOPSIS
      /usr/bin/last [-R] [-count] [name ...] [tty ...]

      /usr/bin/lastb [-R] [-count] [name ...] [tty ...]

 DESCRIPTION

[...]

      The lastb command searches backwards through the database file
      /var/adm/btmp to display bad login information.  Access to
      /var/adm/btmp should be restricted to users with appropriate
      privileges (owned by and readable only by root) because it may
contain
      password information.

Sorry couldn't resist :-)

Martin