If you can use last and get a list of those that have been active for your desired period, then you can use something like:-
You have to be careful that the active list doesn't match multiple accounts, e.g. a user named bob in the active list might also match bobby and you won't see it in the output.
How are your users defined? Are there likely to be false-positives in this?
perhaps you also need to merge your active list with a list of service accounts, e.g. root or oracle or whatever. You need to be sure that your listed idle users are checked before you do anything too drastic with them.
You can get the last login time from the user attributes instead of relying on your last log (we roll ours monthly). This should work but it requires perl to be installed to translate the results into a date and time you can understand:
You can read the users from your /etc/passwd file in a loop:
The result will look similar to this:
Quote:
root Thu Mar 15 10:16:48 2018
daemon Thu Mar 15 10:20:01 2018
bin Thu Mar 15 10:20:01 2018
sys Thu Mar 15 10:20:01 2018
adm Thu Mar 15 10:20:01 2018
uucp Thu Mar 15 10:20:01 2018
guest Thu Mar 15 10:20:01 2018
nobody Thu Mar 15 10:20:02 2018
lpd Thu Mar 15 10:20:02 2018
...
Now that I see it, it may not be accurate for system accounts, but it has been working fine for our individual user accounts. You would have to either grep out your user accounts or "egrep -v" your system accounts.
Hi Experts,
Need your support
Redhat 6.5
I want to create a user with all(read, write, execute) privileges except that user should not be able to create any new user from his login
to perform any task. (10 Replies)
now i have logged in username : ramesh in unix
Now i have to created script file to login into another user and have run a command inside that user and after executing the command i have to exit from that user.
Inside script, i have to login into su - ram along with password : haihow and have to... (4 Replies)
I want to learn AIX. I would like to find someone who would be willing to give me a login to their AIX home lab server. My intent is to poke around and discover the similarities and differences of AIX compared to other *NIXs.
I am a UNIX admin so I can think of what some immediate concerns may... (1 Reply)
Hi Every body,
I would need a shell script program to login as different user and perform some copy commands in the script.
example: Supppose ora_toms is the active user
ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands
... (9 Replies)
Hello World ~
HW : SUN Fire V240
OS : Solaris 8
Error message prompts 'rmclomv ... SC login failure ...' on terminal.
and
Error Message prompts continually 'SC Login Failure for user Please login:' on Single Mode(init S)
The System is in normal operation, though
In case of rain, Can... (1 Reply)
Hi all..
I was trying to do a little shell script, that would list users and their login times, lets say like last 5 days.
But I couldnt figure out how to count users login times from previous days. Any tips?
Funny that nobody has do this kinda script before, or atleast I couldnt find on... (2 Replies)
Hi,
My requirement is that i am login from ROOT in a script but when any
command is coming which is logging to sqlplus then i have to run it with normal user as only normal user have permission to connect to sqlplus .
i tried making a script like this :
#! /bin/ksh
su -... (3 Replies)
I need a script to figure out if a user's last login was 90 days or older. OS=AIX 5.3, shell=Korn
Here's what I have so far:
====
#!/usr/bin/ksh
NOW=`lsuser -a time_last_login root | awk -F= '{ print $2 }'`
(( LAST_LOGIN_TIME = 0 ))
(( DIFF = $NOW - $LAST_LOGIN_TIME ))
lsuser -a... (3 Replies)
I want to delete any file in unix file system which is older then a week.
Those files should not be unix system file..means it should be user created file.
Any clue to this ??
ASAP.
Thanks. (2 Replies)
I created a user, i login as a root. I add him in the group where he can access and login as a root! I checked it in users' list and in group's list, he is there. My problem is this, I cant login using the username/account I just created! What should i do to use and login the user/account i've just... (5 Replies)