01-29-2013
Need help to kill pids
Hi there !!!
I am writing a script to kill the pids on different linux boxes
the output of my command gives the pids running on that box, but how can I kill all the pids without looping?
Code:
ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk '{print $2}' | kill
error:
Usage: kill [-l] [-n signum] [-s signame] job ...
Or: kill [ options ] -l [arg ...]
I tried to dump the output to a file and able to kill the pids using for loop, but looking for one-line code
ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk '{print $2}' | (
how_can_i_kill_here)
Thanks for the help
have a good day
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Is there a command in HP Unix which can be used inside a K shell to find out the maximum number of processes (PIDs) a pc can generate?
Any help will be greatly appreciated.
Steve (8 Replies)
Discussion started by: stevefox
8 Replies
2. Shell Programming and Scripting
I am trying to write a Shell script wherein the shell needs to read a list of PID in the File $stat/bin/Process and compare it to the PID of the processes running on a server.
Also the script should return KO(not OK) with corresponding label :-
a) When an environmental variable not... (2 Replies)
Discussion started by: marconi
2 Replies
3. Shell Programming and Scripting
Hi,
There is a file having a list of running PIDs and another file having a list of registered PIDs. How can we check if the number of running PIDs are less or more than the registered PIDs, comparing the total no. in each and also each value.
Request you to pls give your inputs.
Thanks a... (2 Replies)
Discussion started by: marconi
2 Replies
4. Shell Programming and Scripting
Hi,
There is a file having a list of running PIDs (pid_process) and another file having a list of registered PIDs (pid_regieter).
I want to check if:-
a) there is at least one running PID that does not correspond to a
registered PID (listing the PID not registered in the file)
... (1 Reply)
Discussion started by: marconi
1 Replies
5. Shell Programming and Scripting
I have a script that conducts some SSH calls and I would like to capture the child info so that I can do a sleep and then a cleanup to make sure they do not stay out there as ghosts.
I was told I could do something like this...
#!/bin/sh
for m = job1, job2, job3
x=1... (4 Replies)
Discussion started by: LRoberts
4 Replies
6. Solaris
I am trying to determine the root cause of a java process that dies trying to startup during it's cron job.
I did go ahead and change the time that it starts up in the cron file and now it starts successfully.
However is there a way to determine what PID a process was attempting to get when... (5 Replies)
Discussion started by: vedder191
5 Replies
7. Shell Programming and Scripting
Good afternoon
I need to KILL a process in a single command sentence, for example:
kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'`
That sentence Kills the process ID corresponding to the program CAL255.4ge.
However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies
8. Proxy Server
Details Samba server:
Release: 5.10
Kernel architecture: sun4u
Application architecture: sparc
Hardware provider: Sun_Microsystems
Kernel version: SunOS 5.10 Generic_142909-17
Samba version:
Samba version 3.5.6
Smb.conf file section Global:
# smb.conf for Airbus Industries fuer... (0 Replies)
Discussion started by: Jean-Guillaume
0 Replies
9. Shell Programming and Scripting
im looking for a portable way to get the PID of the script that is running, and to get every other PIDs that are spawned from it.
and by ever other PIDs, i presume, that would be "child processes".
however, i want to shy away from using any command that is not available on every single unix... (1 Reply)
Discussion started by: SkySmart
1 Replies
10. UNIX for Beginners Questions & Answers
First of all, I'd like to congratulate this big family and all members for all the work you do!
I'm trying to do an script or sentence which kills an specific printers PIDs: all printers PIDs older than 72h running in the server.
Steps:
1.- List all printers PID sorting by date:
ps... (6 Replies)
Discussion started by: djflu
6 Replies
PIDOF(8) Linux System Administrator's Manual PIDOF(8)
NAME
pidof -- find the process ID of a running program.
SYNOPSIS
pidof [-s] [-c] [-n] [-x] [-o omitpid[,omitpid..]] [-o omitpid[,omitpid..]..] program [program..]
DESCRIPTION
Pidof finds the process id's (pids) of the named programs. It prints those id's on the standard output. This program is on some systems
used in run-level change scripts, especially when the system has a System-V like rc structure. In that case these scripts are located in
/etc/rc?.d, where ? is the runlevel. If the system has a start-stop-daemon (8) program that should be used instead.
OPTIONS
-s Single shot - this instructs the program to only return one pid.
-c Only return process ids that are running with the same root directory. This option is ignored for non-root users, as they will be
unable to check the current root directory of processes they do not own.
-n Avoid stat(2) system function call on all binaries which are located on network based file systems like NFS. Instead of using this
option the the variable PIDOF_NETFS may be set and exported.
-x Scripts too - this causes the program to also return process id's of shells running the named scripts.
-o omitpid
Tells pidof to omit processes with that process id. The special pid %PPID can be used to name the parent process of the pidof pro-
gram, in other words the calling shell or shell script.
EXIT STATUS
0 At least one program was found with the requested name.
1 No program was found with the requested name.
NOTES
pidof is actually the same program as killall5; the program behaves according to the name under which it is called.
When pidof is invoked with a full pathname to the program it should find the pid of, it is reasonably safe. Otherwise it is possible that
it returns pids of running programs that happen to have the same name as the program you're after but are actually other programs. Note
that that the executable name of running processes is calculated with readlink(2), so symbolic links to executables will also match.
SEE ALSO
shutdown(8), init(8), halt(8), reboot(8), killall5(8)
AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl
01 Sep 1998 PIDOF(8)