Objctive of the above process is to find a process-id and kill it and then restarts the agent again.
I have below 2 scenarios :
(a) If condition - works when a processID is already present and the process ID is killed and then the agent is restarted using following command :
.
(b) Else condition- when the agent is not present then there is no processID. So this else part starts the agent and should exit.
However in this scenario the else part is not working . I believe my below if condition is not working properly
.
Any thoughts or suggestions is appreciated .
You need to preserve the exit code of output=`ps aux|grep hawkagent` , e.g by adding a temporary variable immediately after the command: TMP=$? and checking that afterwards. Or try sth. like
Thanks .
I executed and it worked. Well when i run my code as ./test.sh i get the desired output but the nohup screen doesn't exit.
At some point i shall be calling this .sh file from my ant script.
ps aux and ps -ef print the command arguments, so a grep needs the trick grep "[h]awkagent".
Note the quotes that prevent the shell from matching against files in the current directory.
pgrep does not need the trick.
This User Gave Thanks to MadeInGermany For This Post:
Hi I need to execute the entire line from ANT so i have reduced to a single line entry in ant.
How to combine the below two commands in a single line which finds the PID and also starts my hawkagent ?
I used the below . The agent is killed but the nohup is not starting the agent. Not sure if am missing something.
Last edited by samrat dutta; 08-28-2015 at 01:08 PM..
hi guys
i had written a shell script Display Information of all the File Systems
i want to find the pid and kill the process after few minutes.how can i obtain the pid and kill it???
sample.sh
df -a >> /tmp/size.log
and my cron to execute every minute every hour every day
* *... (5 Replies)
Good afternoon
I need to KILL a process in a single command sentence, for example:
kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'`
That sentence Kills the process ID corresponding to the program CAL255.4ge.
However it is possible that the same program... (6 Replies)
hi,
Am a newbie to unix and wasnt able to write script to my requirement.
I need a shell script, which should find a process by name and kill it. For eg: let the process name be "abc". I have different processes running by this name(abc), so should kill them all.
Condition would be: if... (7 Replies)
Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it
This is how we execute the script (and this is the requirement) ... (2 Replies)
Hi Unix Gurus i am somewhat new to unix scripting so need your help to
create a script as below.
# This script would find the process consuming memory beyond a certain #limit. if the meemory consumption is more than 100% for a period of 1
# minute for the specific process. the script would... (0 Replies)
I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Hi all
i have simple c program , when i wish to kill the app
im using kill(0,-9) , but it seams this command don't do any thing and the program.
just ignore it .
what im doing wrong here ?
im using HP-UX ia64
Thanks (9 Replies)
Hi All,
I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages.
How can i terminate this daemon ? ? ?
Regards,
Vijay Hegde (3 Replies)