Sponsored Content
Full Discussion: How to choose the RIGHT PID?
Top Forums UNIX for Dummies Questions & Answers How to choose the RIGHT PID? Post 302842133 by Igrok on Thursday 8th of August 2013 01:12:57 PM
Old 08-08-2013
How to choose the RIGHT PID?

I can find a single PID and copy it to a variable (thanks to the forum), but I have a slightly tougher situation:

When a user logs into our system, it creates 5 processes

example:
Code:
root     21160  3096  0 07:16 ?        00:00:00 sshd: cs113 [priv]
cs113    21164 21160  0 07:16 ?        00:00:00 sshd: cs113@pts/23
cs113    21165 21164  0 07:16 pts/23   00:00:00 -bash
cs113    21186 21165  0 07:16 pts/23   00:00:00 -bash
cs113    21195 21186  0 07:16 pts/23   00:00:01 rtssyn SYNDRV CS

Sometimes, the user gets logged in multiple times and the system won't let them back in. I want to write a script to identify the PIDs of the user and kill them, so they can log back into the system. To do this currently, I am manually grepping for the PIDS using:

Code:
ps -ef | grep cs113

and I get the result posted in the example. I then proceed to kill the process for cs113 that is owned by root to kill the user's login. example from above:

Code:
kill 21160

Depending on how many logins are in the system, I have to manually kill multiple PIDs.

Again, is there a way to automate the process?

Last edited by Scott; 08-08-2013 at 02:18 PM.. Reason: Please use code tags
 

7 More Discussions You Might Find Interesting

1. Programming

printing ppid,child pid,pid

question: for the below program i just printed the value for pid, child pid and parent pid why does it give me 6 values? i assume ppid is 28086 but can't figure out why there are 5 values printed instead of just two! can someone comment on that! #include<stdio.h> #define DIM 8 int... (3 Replies)
Discussion started by: a25khan
3 Replies

2. UNIX for Dummies Questions & Answers

Session PID & socket connection pid

1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection? 2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)
Discussion started by: pcx26
1 Replies

3. UNIX for Dummies Questions & Answers

Need to get pid of a process and have to store the pid in a variable

Hi, I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this. Thanks in advance, Amudha (7 Replies)
Discussion started by: samudha
7 Replies

4. Programming

GCC: Choose my own linker

Hi, I do not use the default linker, and instead us another one and pass this argument -Wl,--dynamic-linker=<path to linker> to gcc when compiling. However, what happens if the linker is not under /lib and /lib64 and I am not able to create a symlink to the linker in /lib or /lib64 due to no... (2 Replies)
Discussion started by: Shompis
2 Replies

5. Shell Programming and Scripting

choose y or n

Hi, I have written a choice based shell script some thing like this: if (y) execute code .... fi else if(n) terminating the problem with the above scripting is it will work as far as the options are y or n. but i want to reiterate the same code when the user inputs something else... (1 Reply)
Discussion started by: sunrexstar
1 Replies

6. What is on Your Mind?

Which Tablet to Choose?

Currently in the process of looking for a tablet. Which one is best? Thanks Benjamin Mauerberger (9 Replies)
Discussion started by: hlinks12
9 Replies

7. UNIX for Beginners Questions & Answers

Which Product to Choose?

Okay, I have an Asus A8NSLI board with an Athlon 64 and I dunno, maybe 8gig Ram and Windows has crashed for the last time so I've finally had enough and I'll make it a Unix machine. I have a new 1Tera drive and I'm all set to go. Which brand of Unix/Linux can you advise me to go for? The... (3 Replies)
Discussion started by: abrogard
3 Replies
kill.d(1m)							   USER COMMANDS							kill.d(1m)

NAME
kill.d - snoop process signals as they occur. Uses DTrace. SYNOPSIS
kill.d DESCRIPTION
kill.d is a simple DTrace program to print details of process signals as they are sent, such as the PID source and destination, signal num- ber and result. This program can be used to determine which process is sending signals to which other process. Since this uses DTrace, only users with root privileges can run this command. EXAMPLES
Default output, print process signals as they are sent. # kill.d FIELDS
FROM source PID COMMAND source command name TO destination PID SIG destination signal ("9" for a kill -9) RESULT result of signal (-1 is for failure) DOCUMENTATION
See the DTraceToolkit for further documentation under the Docs directory. The DTraceToolkit docs may include full worked examples with ver- bose descriptions explaining the output. EXIT
kill.d will run forever until Ctrl-C is hit. AUTHOR
Brendan Gregg [Sydney, Australia] SEE ALSO
dtrace(1M), truss(1) version 0.90 May 14, 2005 kill.d(1m)
All times are GMT -4. The time now is 01:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy