make fuser send SIGTERM?


 
Thread Tools Search this Thread
Operating Systems HP-UX make fuser send SIGTERM?
# 1  
Old 03-07-2007
make fuser send SIGTERM?

Hello,

Nice forum BTW... anyway on to my question.

I am trying to write a korn shell script that will shut down a java VM. The first challenge was how to figure out which java VM to kill, as there can be other java processes running at the same time.

Then I discovered fuser. It says it will determine the PID if you specify a filename that the process is accessing. Great, I'll just give it the application log path and it will kill the process if I supply the -k option. Unfortunately, this send a SIGKILL to the process. The java process is written to catch a kill signal (SIGTERM) so that it may shutdown gracefully. Is there a way to make fuser send a SIGTERM instead of SIGKILL? I notice that some solaris OSs have an fuser with a -n option to send a SIGTERM, but no such option exists in my version of fuser:

unix version HP-UX hrsut001 B.11.11 U 9000/800 141971547 unlimited-user license

If I can't use fuser, are there any other options on how to write a script that will find and SIGTERM the correct pid?

Thanks!
# 2  
Old 03-07-2007
just get the PID of the process you need to send the signal to and use 'kill' to send a signal.
# 3  
Old 03-07-2007
I need to automate this in a ksh script. How would one find the PID? I suppose I could use fuser and parse the output for the number. The user that will be shutting this process down is not unix savvy. They have to simply be able to type:

shutdown.sh

and hit enter.
# 4  
Old 03-07-2007
Quote:
Originally Posted by adamides
I need to automate this in a ksh script. How would one find the PID? I suppose I could use fuser and parse the output for the number. The user that will be shutting this process down is not unix savvy. They have to simply be able to type:

shutdown.sh

and hit enter.
just as said - write a script to call 'fuser' and parse the output to get the PID(s) of the processes using the file and pass the PID(s) to 'kill -SIGTERM'.
# 5  
Old 03-08-2007
Actually it's easier than that. Apparently when you pipe the output of fuser, only the PIDs are piped. You can simply fuser the file and pipe it to 'xargs kill -SIGTERM'. You can check it out yourself by redirecting the output to a file and then cat'ing it:

[]ksh: /usr/sbin/fuser ../logs/application.log
../logs/application.log: 1297o 1309o

[]ksh: /usr/sbin/fuser ../logs/application.log > out.txt
../logs/application.log: oo
[]ksh: cat out.txt
1297 1309
[]ksh:

Last edited by adamides; 03-08-2007 at 11:05 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

SIGTERM failing in AIX

I have 2 AIX 6.1 systems running on PowerPCs - production and .. .everything else. :p . Until the installation of a TLS certificate in an application, some copying of files ("cloning an environment") and upgrading a listener, sending a kill -15 worked on any script/application, so long as we were... (6 Replies)
Discussion started by: Mrucker
6 Replies

2. UNIX for Advanced & Expert Users

Fuser alternative OR running fuser on a script

Hi, Not sure whether there is a fuser alternative or any better way to check for file in use or not. I am wanting to check whether files are in use or not before removing them. Using fuser, the awk seems to be giving me 'weird' output not to mention that it is giving me 2 lines instead of... (0 Replies)
Discussion started by: newbie_01
0 Replies

3. Shell Programming and Scripting

ksh child process not ignoring SIGTERM

My ksh version is ksh93- =>rpm -qa | grep ksh ksh-20100621-3.fc13.i686 I have a simple script which is as below - #cat test_sigterm.sh - #!/bin/ksh trap 'echo "removing"' QUIT while read line do sleep 20 done I am Executing the script From Terminal 1 - 1. The ksh is started... (3 Replies)
Discussion started by: rpoornar
3 Replies

4. Programming

how can i make that a process child send a signal?

I'm trying to do a program that makes activate an signal (SINGALARM) when the next child of a son appears but this not works. I have to caught the next child o the other (pid), to send a singnal which inform a menssage. It's anything worng in the code? thanks. the code: #include... (2 Replies)
Discussion started by: marmaster
2 Replies

5. Programming

Reliable management of signal SIGPIPE and SIGTERM

I' m note very expert in the reliable manage of signal... but in my server I must manage SIGPIPE for the socket and SIGTERM... I've wrote this but there is something wrong... Can someone explain me with some example the reliable management of signal?? This is what I've wrote in the server ... (2 Replies)
Discussion started by: italian_boy
2 Replies

6. Shell Programming and Scripting

How to detect SIGTERM,SIGKILL signal in UNIX

Dear All We have JBOSS server running on Linux we need to track Graceful Shutdown(SIGTERM) and Forceful Shutdown(SIGKILL) timestamp and write it into one file, I am new to UNIX Signal processing if is it possible how to detect it? We generally do $kill PID For Graceful... (5 Replies)
Discussion started by: mnmonu
5 Replies

7. Shell Programming and Scripting

make un shell script to send email

Hi, Someone Knows how to obtein a chain from a unix file, but not all the line, for exemple, for this file ,obtein only 902111111 and to keep the value, this value will be used to make a mailx. NF=ALL, SUBJ= FROM: SN=CD, SE=TOPCALL, NA=, N=902111111, N=TCLFI TO: SE=FAX, NA=, C1=... (0 Replies)
Discussion started by: peybol
0 Replies

8. Shell Programming and Scripting

Make ssh and send commands

Hi, I'm trying to make an SSH into a SGSN node and collect some commands printouts.:confused: I really don't know how this can be done. I think it must be like this: #!/bin/bash ssh user@192.168.88.10 Then I must enter the password, but I don't know how to do it, I tried with: echo... (3 Replies)
Discussion started by: nagomes
3 Replies

9. Programming

How to implement SIGKILL and SIGTERM and print a message?

Hello, I am running a webserver that uses sockets, forks, and children. The parent process listens for connections and the child processes the information. I am trying to figure out why the code I have below SIGTERM, and SIGKILL never fire. I was messing around with the printfs and doesnt... (11 Replies)
Discussion started by: norelco55
11 Replies

10. Programming

signals - SIGTERM

Hi all, I need some urgent help. we are using Dynix/ptx V4.5 on i386, have several processes and instances are running on the box round the clock.we increased the processes recently. We have coded to handle the signals in our programs. Recently, we noticed most of our processes are... (2 Replies)
Discussion started by: reddyb
2 Replies
Login or Register to Ask a Question