![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [REQ] Automatic script kill process | onisoc | Shell Programming and Scripting | 3 | 05-25-2009 06:17 AM |
| Script to kill process... | malcomex999 | Shell Programming and Scripting | 2 | 03-02-2009 11:29 AM |
| crontab or looping script to Kill process from user | Meert | UNIX for Dummies Questions & Answers | 5 | 02-10-2009 11:08 AM |
| Script to kill process | Lestat | Shell Programming and Scripting | 5 | 06-15-2005 12:09 PM |
| Script to kill all child process for a given PID | sanjay92 | UNIX for Dummies Questions & Answers | 4 | 03-21-2002 03:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grab PID of a process and kill it in a script
Code:
#!/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 I would like to do is take this script a step further and have it auto kill the process by finding the PID after the grep sh and sticking that into the kill string. |
|
||||
|
Code:
ps -t $TERM | grep sh | awk '{print $1}'
Kill -9 ` command` |
| Bits Awarded / Charged to devtakh for this Post | |||
| Date | User | Comment | Amount |
| 05-23-2009 | vidyadhar85 | Great work!! | 1,000 |
|
||||
|
Quote:
|
|
||||
|
Quote:
Code:
ps -t $TERM | awk '/sh/ { print $1 }'
|
|
||||
|
Code:
#!/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 | awk '/sh/ { print $1 }'
read PID
echo "\r"
kill -9 $PID
kill -9 0001 0002 instead of kill -9 0001 0002 how do I get it to read the PID's and put them all into 1 line? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|