bash scripts
I wanted to create a script where it will grep the service, output it into a file and kill the services as listed and print it as a log into other file.
How can i capture only the right name services as other might have the same name. For example, ps -ef | grep vi root 2138 1 0 09:11:41 ? 0:00 vi something1 root 2709 1072 0 09:13:16 ? 0:01 bvia root 1511 1466 0 09:10:40 ? 0:04 asbvi In this case, i just wanted to capture the 'vi' = vi and nothing else...... Can anyone provide a guidance or hints or anything deal with this script? thanks |
try grepping for whole words
Code:
grep -w |
thanks for reply. But in this case, it will still capture the other words contain into it i.e
root 2709 1072 0 09:13:16 ? 0:01 bvia root 1511 1466 0 09:10:40 ? 0:04 asbvi root 1511 1466 0 09:10:40 ? 0:04 grep -w vi The idea is that i want to capture service listing with a spawn child which contain 'vi' and not like ivit, vite or anything. As you can see, it will output the grep and other stuffs. Any better idea how i can capture exact service name 'vi'? Any suggestion are fully welcome. thank you |
Sorry. I did not fully get what you are saying.
Is it something like, you want to find a service which is running and send a kill signal to the process.? In that case you can use "pidof" to find the pid of the process and kill it Code:
/sbin/pidof PROCESS_NAME |
All times are GMT -5. The time now is 03:04 AM. |