killing a process by date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting killing a process by date
# 1  
Old 05-10-2011
killing a process by date

Folks ,

Trying to create a script / command that kills an application process , but on the ones that are from the current date backwards. So far I have everything working minus the "date" part. Can you help me ?

current command :
Code:
kill -9 `ps -aef | grep app_name | grep -v grep | awk '{print $2}'`

This kills everything under the app_name , however I just want to kill process with the app_name from today's current date back ???? and leave just today's

Last edited by Franklin52; 05-12-2011 at 03:23 AM.. Reason: Please use code tags
# 2  
Old 05-10-2011
Please use code tags

Try this
Code:
kill -9 `ps -aef | grep app_name | grep -v grep | awk 'BEGIN {"date +%b%d"|getline dd;}$5!=dd{print $2}'`

regards,
Ahamed
# 3  
Old 05-10-2011
Syntax not correct :


ps -aef | grep naviscore | grep -v grep | awk 'BEGIN {"date +%b%d"|getline dd;}$5!=dd{print $2}'
awk: syntax error near line 1
awk: illegal statement near line 1

Last edited by Franklin52; 05-12-2011 at 03:24 AM.. Reason: Code tags
# 4  
Old 05-10-2011
Quote:
Originally Posted by iMark
Syntax not correct :
Please post the output of "uname -a". If you're on Solaris, use nawk instead of awk.
# 5  
Old 05-11-2011
SunOS nh1a2p32 5.8 Generic_117350-53 sun4u sparc SUNW,Sun-Fire-V440
# 6  
Old 05-11-2011
Yep, that's Solaris. So use nawk rather than awk.
# 7  
Old 05-11-2011
Yep , got that however can not get the part that ahamed101 gave me to work Smilie Wonder if there is an easier way to do this ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Killing the process ID's

Hi , I have a list of application process id's. Is there a way to kill all the process listed below using the script, except the once which are starting with " Genesis " adm 1522 ABC_Process.tra adm 1939 Genesis_Process.tra adm 2729 Genesis_Archive.tra adm 3259 xyz_Process.tra (5 Replies)
Discussion started by: murali1687
5 Replies

2. Shell Programming and Scripting

**need help for killing a process through script**

Hello All, i hope you are fine. I need a little help from you people-- inside a script i want to kill a parent process by checking it with the child process.. p_pid=`ps -e | awk '/ra_cmd_d/ {print$1}'` here i am selecting the child process id in p_pid. next-- sleep_pid=`ps -af |... (3 Replies)
Discussion started by: onlyniladri
3 Replies

3. Shell Programming and Scripting

Finding the age of a unix process, killing old processes, killing zombie processes

I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time. Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies

4. Shell Programming and Scripting

Killing process!!!!

Hi friends, i m in big trouble.... i have one script which connects two server ...like below.. script1.sh ------------------------------------- bash test.sh & eval x=$@ export x=`echo $x` #echo $x # ssh user@8.2.5.6 bash /mbbv/location/script.sh $x|sed '/Binary file/d'... (1 Reply)
Discussion started by: Shahul
1 Replies

5. UNIX for Dummies Questions & Answers

killing the process

Hi, First, I am running a scipt.While the script is running I realize that I dont want the script to be run so I am killing the script externally.Before the process gets terminated or killed it should delete all the temporary files created by the script.How to do this?Can anyone help me? ... (3 Replies)
Discussion started by: arthi
3 Replies

6. Shell Programming and Scripting

Killing of a process and send a mail if the process doesnot come up within 2 minutes

Hi Friends, I am new to this forum as well as new to shell scripting. I have a problem here and i need someone to solve this. Let us consider there are two processes(abc & def).There is a script which kills these two processes(i.e killtheprocess abc). Here abc is the argument . There is a... (1 Reply)
Discussion started by: Prince89
1 Replies

7. Solaris

Reg process of killing

Dear All, I have one doubt - when u use netstat -na | grep 8080 to know the status of 8080 ports.when it is listed someone is accessing the 8080 ports like this *.8080 *.* 0 0 64000 0 LISTEN 172.19.69.39.8080 172.19.50.20.1929 65535 ... (6 Replies)
Discussion started by: shanshine
6 Replies

8. UNIX for Dummies Questions & Answers

killing a process

I can kill running processes on my linux red hat system using ctrl-c but cannot do it from command line of another terminal using kill -2 pid. Although I can kill them from command line using kill -9 pid and other signals. I would like to do it using the kill -2 pid. Thanks for your suggestions (6 Replies)
Discussion started by: bbhayana
6 Replies

9. AIX

killing a process from a script

Hey all. I'm brand new to this forum and am looking for some help. I have a script that verifies that the backup tapes are working correctly. Basically is uses 1 command: restore -xpqvf > rootvglog I use this for each volume group that we have. We run this everyday but the problem is, we... (4 Replies)
Discussion started by: jalge2
4 Replies

10. UNIX for Dummies Questions & Answers

Killing a stubborn process...

I have a stubborn process on my OpenBSD box that just refuses to die. It is taking up about half a meg of memory and refuses to die. It appears to be an errant gzip process that was executed from the console on 06 Jan 2002. Here is a snippet of my attempts to kill the gzip process ... (7 Replies)
Discussion started by: auswipe
7 Replies
Login or Register to Ask a Question