Sponsored Content
Top Forums Shell Programming and Scripting Script to find users not logged in for 90 days Post 302941273 by RudiC on Tuesday 14th of April 2015 04:36:01 PM
Old 04-14-2015
Works for me on Ubuntu linux3.16.0. What's your system and locale?

---------- Post updated at 22:36 ---------- Previous update was at 21:22 ----------

Given you are using awk anyhow, and several times, and hoping your date will eventually work, you might want to consider replacing your script with (an extended version of) this:
Code:
awk -F: '
BEGIN   {NOW=srand()}           

        {("last -1 " $1) | getline PW
         split (PW, USR, " ")
         if (USR[1]==$1)        {printf "%s %s, ",  $1, substr (PW, 40, 13)
                                 ("date +%s -d\""substr(PW, 40, 13)"\"") | getline LOG
                                 printf "%s\n", " logged in " int((NOW-LOG)/86400) " days ago."
                                }
         else print $1 " never logged in so far."
        }
        ' /etc/passwd


Last edited by RudiC; 04-16-2015 at 05:18 AM.. Reason: Typo correction
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

to find the number of users logged in

Hi, can u say to display the number of users that logged before me. thanks (10 Replies)
Discussion started by: shanshine
10 Replies

2. UNIX for Dummies Questions & Answers

List all inactive users who has not logged on since last 90 days

Hi, Can I get a script to list out all the users, who has not logged on since last 90 days. Last command in not working due due to /var/adm/wtmpx is more than 2 GB. Thanks in advance. Regards, Roni (10 Replies)
Discussion started by: manasranjanpand
10 Replies

3. Solaris

List all inactive users who has not logged on since last 90 days

I need actuall script which List all inactive users who has not logged on since last 90 days Thanks in advance. Di! (17 Replies)
Discussion started by: haridham
17 Replies

4. Shell Programming and Scripting

Script to check users logged out

Hi, Here is the script that I have written to check if a particular user is has logged out, and if yes, then a mail needs to be sent to the management the details of whatever has been captured by the script command. echo "The current users are:" who | awk '{print $1}' | sort > temp1 cp... (1 Reply)
Discussion started by: ggayathri
1 Replies

5. Shell Programming and Scripting

Script to identify logged users & commands executed

Hi All, I am trying to write a script to get the user information & the command executed. I tried something like this : w | sort | awk '{print$5$6$7}' My requirement is to identify the users who execute the same command at same time. I need the user name & the... (2 Replies)
Discussion started by: vijayarajvp
2 Replies

6. Shell Programming and Scripting

number of users logged in script

My admin needs a shell script in Korn that will show conditions based on users logged in. I have never used the Korn shell and have no clue what I am doing, can anyone help. here are the conditions that need to be returned. if users are below 5 displays should be: performance is high if... (1 Reply)
Discussion started by: vthokiefan
1 Replies

7. Shell Programming and Scripting

find top 4 users currently logged on can i use grep

For the first 4 users only that are currently logged in output their effective user id. It's not important the order in which each logged in i just want to have the top 4. Same question as here...... (0 Replies)
Discussion started by: whyatepies
0 Replies

8. UNIX for Dummies Questions & Answers

how to find top 3 users currently logged on

For the first 3 users only that are currently logged in output their effective user id. thank you. (6 Replies)
Discussion started by: whyatepies
6 Replies

9. Shell Programming and Scripting

Users not logged in for last 90 days

Hi, How to find the users who did not login into a UNIX box (thru ssh/ftp or any other way) for last 90 days? I think of using "finger" or "last" command to findout each user's last login and then find number of days between today and that day. Is there any other better way or anyone prepared... (1 Reply)
Discussion started by: reddyr
1 Replies
ZLOCATE(1)						      General Commands Manual							ZLOCATE(1)

NAME
zlocate - find a user using Zephyr SYNOPSIS
zlocate [ -a | -d ] [ -1 ] [ -p ] user ... DESCRIPTION
Zlocate uses the Zephyr(1) Notification Service to find where a user is currently logged in. If the user is not logged in, or has set his location information such that you do not have access to see it, zlocate prints "Hidden or not logged-in". Otherwise, each machine that the user is currently logged into is printed, along with the time of login and location. The location is usually the X window system dis- play name of the user's display, but may be the terminal name if he is not using X or for some other reason is only using the terminal interface to zwgc(1). By default, all zlocate requests are authenticated using Kerberos. If you do not have Kerberos tickets, or for some other reason do not want to authenticate, the -d option will turn off authentication. The -a option is the default, authentication on. When locating multiple users, zlocate will display the user name on a line by itself, followed by the locations for that user. To display the user name on the same line as the output, use the -1 option (the numeral one). To look up multiple users in parallel asynchronously, use the -p option. DIAGNOSTICS
zlocate exits with status zero (0) if at least one user was found, and one (1) if no users were found. SEE ALSO
zctl(1), zephyr(1), znol(1), zwgc(1), zhm(8), zephyrd(8), X(1) Project Athena Technical Plan Section E.4.1, `Zephyr Notification Service' AUTHORS
Robert S. French (MIT-Project Athena) Marc Horowitz (MIT-Project Athena) RESTRICTIONS
Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. All Rights Reserved. zephyr(1) specifies the terms and conditions for redistribution. MIT Project Athena April 17, 1990 ZLOCATE(1)
All times are GMT -4. The time now is 01:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy