Sponsored Content
Top Forums Shell Programming and Scripting How to display what processes, users have opened at a given time Post 302367379 by jim mcnamara on Monday 2nd of November 2009 11:26:15 AM
Old 11-02-2009
Code:
who | awk '{print $1}' > t.sed; ps -ef | grep -f t.sed | awk '{arr[$1]++} END{ for (i in arr){print arr[i], i}}' | sort -rn

If this is homework, your prof is not likely to believe you wrote this...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Users and processes

Hi All, I am trying to write a script to list all users and their processes. I cant seem to find out how to link the PID to the user. For example if i run ps -a I get a nice list of all the processes running and their PID, but no information about which user is running them. If i use w i... (17 Replies)
Discussion started by: Chiefos
17 Replies

2. Shell Programming and Scripting

Displaying the processes of users

Hi guys, I'm writing a script to display all the current logged on users and the processes they're running, output to a file. The output will look similar to this: User1 (Real name not login name) PID TTY TIME CMD 3179 pts/3 00:00:00 vim User2 PID TTY TIME ... (2 Replies)
Discussion started by: olimiles
2 Replies

3. UNIX for Dummies Questions & Answers

Command to find last time file was opened

New to unix .. Is there a simple command or utility that will tell me when the last time a file was opened/used? (3 Replies)
Discussion started by: sbr262
3 Replies

4. UNIX for Dummies Questions & Answers

users and there processes

I am trying to write a script to list all users and their processes. I cant seem to find out how to link the PID to the user. For example if i run ps -a I get a nice list of all the processes running and their PID, but no information about which user is running them. I need the users real name not... (3 Replies)
Discussion started by: iago
3 Replies

5. Shell Programming and Scripting

Processes and Users

Thx for all the help so far, I really appreciate it, this is the last task I have to do then I am no longer a trainee ^^, which means I can use whatever utility I want. :O I need to write a script that does more or less what is shown below. The Users Name PID TTY TIME CMD 12345 pts/3... (22 Replies)
Discussion started by: barbus
22 Replies

6. Shell Programming and Scripting

printing each users by processes

hello All, i am trying to get the each users by with thier processing. I have try it in several ways but i am not getting thier my code is #!bin/bash/ users=`cat /etc/passwd | cut -d':' -f5` onlineusers=`users | tr '.' ' '` $onlineusers | while read `$users` do echo `ps -U $users`... (12 Replies)
Discussion started by: sam4now
12 Replies

7. UNIX for Advanced & Expert Users

same file being opened by two users at a time

I want to avoid a situation where because two users simultaneously open a file and modify and save, leaving the original file in mess. Is there a way in UNIX to warn a user if that particular file is already being used by another user. Thanks in advance (3 Replies)
Discussion started by: paresh n doshi
3 Replies

8. Shell Programming and Scripting

Scripting Help - Display Processes

Hi, I was wondering if somebody could help me as I am struggling with writing a script for a training course. Ive had to write 5 scripts and this is the last one but am struggling with this even though I understand what it is meant to do..... PROBLEM: write a script which will allow you to... (1 Reply)
Discussion started by: isxrc
1 Replies

9. Homework & Coursework Questions

Display info about users (UID GID processes terminal)

I would like to get an opinion for my solution for this task and get feedback about better approach or mistakes I have made. 1. The problem statement, all variables and given/known data: The task is to create a script which prints information about users whose names are specified in the... (2 Replies)
Discussion started by: kornfan
2 Replies

10. UNIX for Beginners Questions & Answers

How to display processes which have been running for more than a X hours?

Hi, Is it possible to display processes which have been running for more than a 5hrs using a variation of the ps -ef command? Regards, Manny (5 Replies)
Discussion started by: mantas44
5 Replies
LASTLOG(8)						    System Management Commands							LASTLOG(8)

NAME
lastlog - reports the most recent login of all users or of a given user SYNOPSIS
lastlog [options] DESCRIPTION
lastlog formats and prints the contents of the last login log /var/log/lastlog file. The login-name, port, and last login time will be printed. The default (no flags) causes lastlog entries to be printed, sorted by their order in /etc/passwd. OPTIONS
The options which apply to the lastlog command are: -b, --before DAYS Print only lastlog records older than DAYS. -h, --help Display help message and exit. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. -t, --time DAYS Print the lastlog records more recent than DAYS. -u, --user LOGIN|RANGE Print the lastlog record of the specified user(s). The users can be specified by a login name, a numerical user ID, or a RANGE of users. This RANGE of users can be specified with a min and max values (UID_MIN-UID_MAX), a max value (-UID_MAX), or a min value (UID_MIN-). If the user has never logged in the message ** Never logged in** will be displayed instead of the port and time. Only the entries for the current users of the system will be displayed. Other entries may exist for users that were deleted previously. NOTE
The lastlog file is a database which contains info on the last login of each user. You should not rotate it. It is a sparse file, so its size on the disk is usually much smaller than the one shown by "ls -l" (which can indicate a really big file if you have in passwd users with a high UID). You can display its real size with "ls -s". FILES
/var/log/lastlog Database times of previous user logins. CAVEATS
Large gaps in UID numbers will cause the lastlog program to run longer with no output to the screen (i.e. if in lastlog database there is no entries for users with UID between 170 and 800 lastlog will appear to hang as it processes entries with UIDs 171-799). shadow-utils 4.1.5.1 05/25/2012 LASTLOG(8)
All times are GMT -4. The time now is 02:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy