Hi
I want to write a script for snoop which can do snoop for 30 min and then process should be killed automatically
I am using below codes
#!/usr/bin/ksh
snoop -d igb0 -o /opt/temp/abc.pcap
sleep 1500
kill -9 `ps -ef|grep -i snoop |grep -v grep|awk '{print $2}'`
But process is not getting killed .Can anyone help me for above requirement.
PikK45
2
Can you try executing the
ps -ef|grep -i snoop |grep -v grep|awk '{print $2}'
and see what is the output that u get!?
Also try to see whether that just returns one ID which is its process ID!!
Its returning process ID
>ps -ef | grep -i snoop
root 26288 21712 0 11:33:48 pts/2 0:00 sh snooptest.sh
root 26303 23695 0 11:33:52 pts/3 0:00 grep -i snoop
nobody 26289 26288 0 11:33:48 pts/2 0:00 snoop -q -d igb0 -o /opt/temp/abc.pcap
> ps -ef | grep -i snoop | grep -v grep | awk '{print $2}'
26288
26289
but sometimes it is not able to kill the process and process is running in background
PikK45
4
For this you have to grep for /opt/temp/abc.pcap so that it just gives you single ID!! Hope this will help!