Ending user sessions which have been on a program for longer than 1 hour

hi,

im looking to write a script to end user sessions which are on a paticular program and have been for over an hour so I can free up the system a bit.
I understand that the "who" command lists the current users logged into the system, however it does not let me see what program they are on and how long they have been on it.

If i do a

ps -ef | grep <username>

then this does provide me with the information I need, question is how do I get it to grep not just one username but every user that is logged into the system currently.

Any help would be massively appreciated

from the who command get the user logged in and save in file and from ps -ef get the processes running for more than hours and use grep -f saved_file for the processes of user currently logged in.

ps -eo user,cmd,start_time

will output a list like

JohnF     cat         15:00

You could grep for your progname and have what you requested for.

1 Like

Cheers RudiC :slight_smile:
My ps doesnt like those formats so Ive decided to go along with this which gives me what I require thing is now I don't know how I can kill the user off using the PID without any intervention.

ps -aef | grep Aug | grep me1010

The PID for the user is in the third column along

---------- Post updated at 09:00 AM ---------- Previous update was at 08:59 AM ----------

This is the output of the command Ive just mentioned, PID is in the third column

rigbyt  4766  4607   0   Aug 08 pts/124     0:05 /apps/progress//bin/_progres -p me1010rf.p -pf /apps/live/awards/data/awards.pf

As root you can issue kill PID which will send the default TERM (#15) to that process. If that doesn't work, issue kill -9 PID which cannot be blocked by the receiving process. It may be neccessary to inform users beforehand, e.g. using write user .

Does your ps not allow for any formatting/column selection?

this is the format of the ps command I currently have,

Yes thats a good idea Ill incorportae that in the script somewhere

Did you try the user,stime,comm format selectors? Or fname?

1 Like

thats seems to work cheers :slight_smile:

As a rule, if you're doing grep | grep | grep -v | sed | cut | kitchen | sink, you can rewrite it as a single awk.

awk '/[m]atch1/ && /[m]atch2/ && !/[m]atch3/ { print $5 }'

The first character of the regexes is obscured in [] so awk doesn't match itself in a ps listing.

5 just means the 5th column, adjust to taste.

1 Like

Thankyou for the help :slight_smile:

@02JayJay02
Please post what Operating System and version you have and what Shell you are running.
There is much variation in the ps command.

Please post what version of Progress you are running.

Do not, I repeat do not ever issue "kill -9" to a Progress database session which is connected to the current Progess instance. It will corrupt your database. Obviously no problem if the database has been restarted in the meantime and these are orphan clients which the database engine could not clean up for some reason (like they were stuck on I/O to a failed disc drive).

Please note that there is a proper procedure for removing Progess client sessions through the Progress promon utility.

If these are telnet clients, issuing kill -15 to the telnet process will trigger a hangup and cause the database engine to clean up the dead session. This is a safe approach because it triggers Before Image rollback of any active transactions .

Please note that there is a proper sequence of kill signals which will be documented for your version of Progress.

1 Like

Hi methyl,

SunOS 5.10
Progress Version 9.1E
Im using the bash shell

Thankyou for the info I have been told never to issue a Kill -9 command as it is very dangerous to do, I am aware of the Progress commands however I am not familiar with them, you wouldn't happen to have any documentation on progress commands?

Thanks for your help

Progress 9 product came with a comprehensive manual set. Because of that I never needed an online version.

To check you exact Progress software version, use the version command which comes with Progress. It will be something like 9.1D or 9.1E I guess.

Your version is out of date and no longer mentioned on the Progress website Application Development, SaaS, Cloud Deployment, Complex Event Processing, Data Connectivity and Real Time Decisions Products | Progress Software.

The oldest online documentation for Progress appears to be OpenEdge 10 (the "new" name for Progress):
Progress Communities: OpenEdge 10.1C Product Documentation Overview

1 Like