Safe script to kill processes

  • Follow


Could somebody give me some suggestions on how to write a safe shell
script to kill remote processes?

Two Solaris 2.5.1 SPARCstation (A and B) on a common Ethernet. Remote
accesses (each other) through rlogin and X protocol are allowed. A is
used as a software server, and running other real-time control
processes, really critical. We rlogin to A from B, start applications
for B with "-display B:0.0" argument.

Now I'd like a safe, conservative shell script to rlogin to A and kill
those processes started for B, then restart them again. Other processes
on A are too important to be killed by mistake. Is it okay to "grep"
"ps"'s output, then "sed" for process names with "-display B:0.0"?

Wei

0
Reply leethium (1) 9/17/2005 8:12:29 AM

Wei wrote:
> [...]
> Two Solaris 2.5.1 SPARCstation (A and B) on a common Ethernet. Remote
> accesses (each other) through rlogin and X protocol are allowed. A is
> used as a software server, and running other real-time control
> processes, really critical. We rlogin to A from B, start applications
> for B with "-display B:0.0" argument.
> [...]

Solaris 2.5.1 support ends next thursday (EOSL 09/22/05), I wouldn't run
"really critical" processes on that platform.
0
Reply Jean 9/17/2005 12:53:21 PM


Thanks for your reminder, but that's sort of something I can't control.
: (

I'm not familiar with Solaris. Hence, not sure about the differences of
process system and tools (eg. sed, ps, ...) between Solaris and
GNU/Linux. Any place that should be paid special attention to when
writing such a process killing script?

0
Reply Wei 9/18/2005 12:17:13 AM

Wei wrote:
> Thanks for your reminder, but that's sort of something I can't control.
> : (
> 
> I'm not familiar with Solaris. Hence, not sure about the differences of
> process system and tools (eg. sed, ps, ...) between Solaris and
> GNU/Linux. Any place that should be paid special attention to when
> writing such a process killing script?
> 

The issue is not here Gnu utilities vs Solaris, the issue is Solaris
2.5.1, which (probably?) lacks commands that would be used on current
Solaris releases, like pgrep or pkill.
0
Reply Jean 9/18/2005 8:00:06 AM

Yes, you're right. There's no pkill or pgrep in Solaris 2.5.1. Given
the fact that I can't upgrade the OS, is it possible to implement
similar functionalities with shell scripts? (Or other commands?)

0
Reply Wei 9/18/2005 8:45:43 AM

HI,

Jean-Louis Liagre wrote:
> Wei wrote:
> 
>> [...]
>> Two Solaris 2.5.1 SPARCstation (A and B) on a common Ethernet. Remote
>> accesses (each other) through rlogin and X protocol are allowed. A is
>> used as a software server, and running other real-time control
>> processes, really critical. We rlogin to A from B, start applications
>> for B with "-display B:0.0" argument.
>> [...]
> 
> 
> Solaris 2.5.1 support ends next thursday (EOSL 09/22/05), I wouldn't run
> "really critical" processes on that platform.
On the other hand, since it's been around for 9-10 years, I would prefer 
2.5.1 compared to S9/S10 on a critical system :)

/michael

0
Reply Michael 9/18/2005 1:58:16 PM

HI,

Wei wrote:
> Could somebody give me some suggestions on how to write a safe shell
> script to kill remote processes?
> 
> Two Solaris 2.5.1 SPARCstation (A and B) on a common Ethernet. Remote
> accesses (each other) through rlogin and X protocol are allowed. A is
> used as a software server, and running other real-time control
> processes, really critical. We rlogin to A from B, start applications
> for B with "-display B:0.0" argument.
> 
> Now I'd like a safe, conservative shell script to rlogin to A and kill
> those processes started for B, then restart them again. Other processes
> on A are too important to be killed by mistake. Is it okay to "grep"
> "ps"'s output, then "sed" for process names with "-display B:0.0"?
> 
> Wei
> 
Not at all any PRO in this but would it help to store the PID of the 
started process(s) for later use when running kill -9/15 on that PID?

This way you would keep track of all started processes.

/michael

0
Reply Michael 9/18/2005 2:02:20 PM

Wei wrote:
> Yes, you're right. There's no pkill or pgrep in Solaris 2.5.1. Given
> the fact that I can't upgrade the OS, is it possible to implement
> similar functionalities with shell scripts? (Or other commands?)
> 

pgrep/pkill code is actually open source now:

http://cvs.opensolaris.org/source/xref/usr/src/cmd/pgrep/

I've no idea about if this source will directly compile
on 2.5.1 or if some porting effort would be required though.

0
Reply Jean 9/18/2005 3:09:53 PM

Michael Laajanen wrote:

> HI,
> 
> Wei wrote:
> 
>> Could somebody give me some suggestions on how to write a safe shell
>> script to kill remote processes?
>>
>> Two Solaris 2.5.1 SPARCstation (A and B) on a common Ethernet. Remote
>> accesses (each other) through rlogin and X protocol are allowed. A is
>> used as a software server, and running other real-time control
>> processes, really critical. We rlogin to A from B, start applications
>> for B with "-display B:0.0" argument.
>>
>> Now I'd like a safe, conservative shell script to rlogin to A and kill
>> those processes started for B, then restart them again. Other processes
>> on A are too important to be killed by mistake. Is it okay to "grep"
>> "ps"'s output, then "sed" for process names with "-display B:0.0"?
>>
>> Wei
>>
> Not at all any PRO in this but would it help to store the PID of the 
> started process(s) for later use when running kill -9/15 on that PID?
> 
> This way you would keep track of all started processes.
> 
> /michael
> 
That would be the best way but, not having that,
the PID you can get with
ps -ef |grep <string> |grep -v grep |awk '{print $2}'
I would test the script using "echo" instead of "kill" (maybe redirected 
to a file or something)
0
Reply Jaime 9/25/2005 2:42:01 PM

Jaime Cardoso <jaimec@solsuni.pt> writes:

> That would be the best way but, not having that,
> the PID you can get with
> ps -ef |grep <string> |grep -v grep |awk '{print $2}'
> I would test the script using "echo" instead of "kill" (maybe redirected to
> a file or something)

Or use pkill(1). It's Solaris, after all.

Bye, Dragan

-- 
Dragan Cvetkovic, 

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!
0
Reply Dragan 9/27/2005 7:06:54 PM

Dragan Cvetkovic <me@privacy.net> writes:

> Jaime Cardoso <jaimec@solsuni.pt> writes:
>
>> That would be the best way but, not having that,
>> the PID you can get with
>> ps -ef |grep <string> |grep -v grep |awk '{print $2}'
>> I would test the script using "echo" instead of "kill" (maybe redirected to
>> a file or something)
>
> Or use pkill(1). It's Solaris, after all.
>

Never mind pkill. Didn't notice OP was talking about Solaris 2.5.1

Dragan

-- 
Dragan Cvetkovic, 

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!
0
Reply Dragan 9/27/2005 7:07:54 PM

Thanks for all of you! And to Jaime: yeah, your grep with -v argument
is exactly what I want to simplify my original script. I'm too silly to
overlook it. Thank you!

0
Reply Wei 9/29/2005 1:12:35 PM

11 Replies
628 Views

(page loaded in 8.235 seconds)

Similiar Articles:


















7/24/2012 2:20:14 PM


Reply: