Sponsored Content
Top Forums Shell Programming and Scripting Unix Script -- Suggestions to list and kill PID's sequentially Post 302665799 by murali1687 on Tuesday 3rd of July 2012 07:58:52 AM
Old 07-03-2012
Unix Script -- Suggestions to list and kill PID's sequentially

Hi,
I'm trying to write a script where i'm trying to grep the PID and the associated file and list them. Then execute the KILL command sequentially on the listed PID's for ".tra" files
Code:
====================================================
ps -aux | grep mine

adm   27739  0.2  0.8 1131588 277496 ?  Sl   May29 129:13 /opt/bin/mine  --pid --run --propFile /opt/tib/tra/domain/eng/ABC_Process.tra  --innerProcess
adm   28765  0.8  1.6 1015652 533404 ?  Sl   Jun12 250:24 /opt/bin/mine  --pid --run --propFile /opt/tib/tra/domain/eng/XYZ_Process.tra  --innerProcess
adm   29132  1.6  2.9 1618840 970624 ?  Sl   Jun23 214:49 /opt/bin/mine  --pid --run --propFile /opt/tib/tra/domain/eng/BCY_Archive.tra  --innerProcess
=====================================================

Expecting Output like:
Code:
================
adm  27739  ABC_Process.tra
adm  29132   BCY_Archive.tra

--- Murali.
Moderator's Comments:
Mod Comment Please use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to kill all child process for a given PID

Is there any build in command in unix to kill all the child process for a given process ID ? If any one has script or command, please let me know. Thanks Sanjay (4 Replies)
Discussion started by: sanjay92
4 Replies

2. Shell Programming and Scripting

pass pid to kill using script

Hi there, i wonder if anyone can help is there any way that i can write a script that will kill all current ftp processes, for example if ps -ef | grep ftp produces 3 active proceses, then I would like to somehow extract the PID for each one and pass that to kill -9 has anybody done this... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

3. Shell Programming and Scripting

KILL PID, intern should kill another PID.

Hi All, In my project i have two process runs in the back end. Once i start my project, and execute the command ps, i get below output: PID TTY TIME CMD 9086 pts/1 0:00 ksh 9241 pts/1 0:02 java 9240 pts/1 0:00 shell_script_bg java with 9241 PID is the main... (4 Replies)
Discussion started by: rkrgarlapati
4 Replies

4. UNIX for Advanced & Expert Users

KILL without PID

Hellow Experts i have one problem. i run one script in backgroun. and i want to kill that script with only script name..... so what's the solution.. for your info my script name is "testscript" n it contains "sleep 100" thanks.... (16 Replies)
Discussion started by: luckypower
16 Replies

5. Shell Programming and Scripting

grab PID of a process and kill it in a script

#!/bin/sh who echo "\r" echo Enter the terminal ID of the user in use: echo "\r" read TERM_ID echo "\r" ps -t $TERM_ID | grep sh echo "\r" echo Enter the process number to end: echo "\r" read PID echo "\r" kill -9 $PID What this code does is ultimately grab the PID of a users sh... (6 Replies)
Discussion started by: psytropic
6 Replies

6. UNIX for Dummies Questions & Answers

Run Processes Sequentially Using Process ID (PID)

Hi, I'm a newbie when it comes to using UNIX, and I'm hoping someone here can help me out. I have a set of processes that I want to run sequentially: process1.py process2.py process3.py I want to know I can run these sequentially using their process IDs (PIDs). Ideally, I want to... (2 Replies)
Discussion started by: shelata
2 Replies

7. Shell Programming and Scripting

Kill a Script based on the pid and sleep

I would want to run a code for 1 min and if it doesnt succeed in 1 min..I would want to exit it..I am using the following code...But the script is not going into my code part.It is waiting for 60 secs and then getting killed. The code which is in the while loop actually takes less than 60 secs...... (6 Replies)
Discussion started by: infernalhell
6 Replies

8. Shell Programming and Scripting

Kill a PID using script

Hi, I wrote a script to kill a process id. I am able to kill the PID only if I enter the root password in the middle of the execution because I did not run as root i.e after i run the script from the terminal, instead of killing directly, it is killing only after entering the pass when it... (12 Replies)
Discussion started by: rajkumarme_1
12 Replies

9. Shell Programming and Scripting

script to kill a pid giving error

Hi, I simply want to kill a running process using a script that read pid from a file and tries to kill it .Getting error as shown below code.. cat $HOME/BackupScript.ksh.run | head -1 | while read pid do ps -p $pid > /dev/null 2>&1 if ; then kill -9 $pid else echo "no running $pid... (5 Replies)
Discussion started by: dhirajdsharma
5 Replies

10. Shell Programming and Scripting

Shell script to report file size, pid and also kill the process

Hi All, Looking for a quick LINUX shell script which can continuously monitors the flle size, report the process which is creating a file greater than certain limit and also kill that process. Can someone please help me on this? (4 Replies)
Discussion started by: vasavimacherla
4 Replies
KILL(1) 							   User Commands							   KILL(1)

NAME
kill - send signals to processes, or list signals SYNOPSIS
kill [-s SIGNAL | -SIGNAL] PID... kill -l [SIGNAL]... kill -t [SIGNAL]... DESCRIPTION
Send signals to processes, or list signals. Mandatory arguments to long options are mandatory for short options too. -s, --signal=SIGNAL, -SIGNAL specify the name or number of the signal to be sent -l, --list list signal names, or convert signal names to/from numbers -t, --table print a table of signal information --help display this help and exit --version output version information and exit SIGNAL may be a signal name like `HUP', or a signal number like `1', or the exit status of a process terminated by a signal. PID is an integer; if negative it identifies a process group. NOTE: your shell may have its own version of kill, which usually supersedes the version described here. Please refer to your shell's docu- mentation for details about the options it supports. AUTHOR
Written by Paul Eggert. REPORTING BUGS
Report kill bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
kill(2) The full documentation for kill is maintained as a Texinfo manual. If the info and kill programs are properly installed at your site, the command info coreutils 'kill invocation' should give you access to the complete manual. GNU coreutils 7.1 July 2010 KILL(1)
All times are GMT -4. The time now is 09:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy