Sponsored Content
Full Discussion: Find users in 24 hour
Top Forums Shell Programming and Scripting Find users in 24 hour Post 302786053 by Chubler_XL on Tuesday 26th of March 2013 06:37:16 PM
Old 03-26-2013
You could process the output of last -t looking for "gone - no logout" where users are in at a particular time:

Here is split that day up into 5min blocks and check each block:

Code:
STS=$(date -d "$*" +%s)
INC=0
MAX=0
while [ $INC -lt $((60*60*24)) ]
do
   CNT=$(last -t $(date -d @$((STS+INC)) +%Y%m%d%H%M%S) | grep "gone" | wc -l)
   if [ $CNT -gt $MAX ]
   then
       MTIME=$((STS+INC))
       MAX=$CNT
   fi
   let INC=INC+5*60
done

echo "Maximum users: $MAX at $(date -d @$MTIME)"

Call it like this:

Code:
$ max_user.sh 26 Mar 2013
Maximum users: 4 at Tue Mar 26 15:05:00 EST 2013

---------- Post updated at 08:37 AM ---------- Previous update was at 08:26 AM ----------

Note: this is very dependent on your last -t command output under Fedora I get something like this, which is what I developed/tested with:

Code:
last -t 20120727163900
chubler  pts/1        192.168.1.3      Fri Jul 27 16:38    gone - no logout 
chubler  pts/1        192.168.1.3      Fri Jul 27 16:38 - 16:38  (00:00)    
chubler  pts/1        192.168.1.3      Fri Jul 27 16:36 - 16:36  (00:00)    
chubler  pts/1        192.168.1.3      Fri Jul 27 16:34 - 16:34  (00:00)    
chubler  pts/0        :0               Fri Jul 27 16:25    gone - no logout 
chubler  :0           :0               Fri Jul 27 16:14    gone - no logout

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl find directory only if modified in last hour

I want a one liner perl command to find a directory only if the modified time is within the last hour I am running this on windows - and I will define a variable for the result. So for example I want to return value of 1 for the variable if the modified time of d:\test1 is within the last... (0 Replies)
Discussion started by: frustrated1
0 Replies

2. Solaris

Find any spike in CPU usage a hour ago

Folks, I need to find out from the system logs ( or elsewhere ) if the CPU utilization reached say 90% an hour ago from now. Is there a way out. (2 Replies)
Discussion started by: kavera
2 Replies

3. Shell Programming and Scripting

Find files modified in last hour sunOS 5.10

trying to find a way to locate files modified in the last hour in a shell script, unfortunately the command 'find . -mmin -60' is not supported on SunOS 5.10 (works on OpenSolaris 5.11 :mad:) Does anyone know a method of doing this in shell script on 5.10? cheers (19 Replies)
Discussion started by: rich@ardz
19 Replies

4. UNIX for Dummies Questions & Answers

HP UNIX: How to find files which are older than one hour.

HP Unix Version: HP-UX B.11.31 U ia64 Question I look for script or command to find files which are older than one hour. Tried below; # set the file time to 1 hours ago touch -t 201307160700 ./touchfile find /app/grid/product/11.2.0.3/rdbms/audit -name '*.aud' -type f ! -newer... (4 Replies)
Discussion started by: Siva SQL
4 Replies

5. Shell Programming and Scripting

List last 1 hour files with out FIND command

Hi Friends, Can we have an alternate command to list last 1hour files with out FIND command? Thanks Suresh (6 Replies)
Discussion started by: suresh3566
6 Replies

6. Shell Programming and Scripting

How to find the files created within one hour in Solaris?

Hi Gurus, I want to find the file created within one hour in solaris. I have tried below command, but it is no lucky. $find . -mtime -1/24, -name "abc*" above command give me the file name which created two hours ago find . -cmin -60, -name "abc*" above command I got error as... (4 Replies)
Discussion started by: ken6503
4 Replies

7. Shell Programming and Scripting

Command to find files older than 1 hour

Hi, Out of a list of files in a directory, I want to find the files which were created/modified more than 1 hour ago. I am using HP -UNIX and it does not support the argument -mmin. Please advise. I am using # !/bin/sh (4 Replies)
Discussion started by: jhilmil
4 Replies
sulog(4)							   File Formats 							  sulog(4)

NAME
sulog - su command log file SYNOPSIS
/var/adm/sulog DESCRIPTION
The sulog file is a record of all attempts by users on the system to execute the su(1M) command. Each time su(1M) is executed, an entry is added to the sulog file. Each entry in the sulog file is a single line of the form: SU date time result port user-newuser where date The month and date su(1M) was executed. date is displayed in the form mm/dd where mm is the month number and dd is the day number in the month. time The time su(1M) was executed. time is displayed in the form HH/MM where HH is the hour number (24 hour system) and MM is the minute number. result The result of the su(1M) command. A ` + ' sign is displayed in this field if the su attempt was successful; otherwise a ` - ' sign is displayed. port The name of the terminal device from which su(1M) was executed. user The user id of the user executing the su(1M) command. newuser The user id being switched to with su(1M). EXAMPLES
Example 1: A sample sulog file. Here is a sample sulog file: SU 02/25 09:29 + console root-sys SU 02/25 09:32 + pts/3 user1-root SU 03/02 08:03 + pts/5 user1-root SU 03/03 08:19 + pts/5 user1-root SU 03/09 14:24 - pts/5 guest3-root SU 03/09 14:24 - pts/5 guest3-root SU 03/14 08:31 + pts/4 user1-root FILES
/var/adm/sulog su log file /etc/default/su contains the default location of sulog SEE ALSO
su(1M) SunOS 5.10 6 Jun 1994 sulog(4)
All times are GMT -4. The time now is 02:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy