LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices



Reply
 
Search this Thread
Old 10-17-2008, 09:51 AM   #1
Rocket2DMn
LQ Newbie
 
Registered: May 2007
Location: Pennsylvania
Distribution: Ubuntu, CentOS/RHEL, Solaris
Posts: 5

Rep: Reputation: 0
Start/Stop/Status init scripts


I am writing a custom legacy init script in Solaris 10 for testing purposes, which will be executing a dummy java program called SocketEcho. The problem is, I do not know how to stop the program correctly.
"pidof" is not available (from what I can tell).

I will start the program with
Code:
/opt/SocketEcho/SocketEcho
That SocketEcho script simply runs
Code:
java SochetEcho
in that same directory which has the class file. This works fine when executed manually (will test script functionality later), then I send it to the background.

Now I have to stop the program with
Code:
/etc/init.d/solarisSocketEcho stop
When running
Code:
ps -ef | grep SocketEcho
I see the process listed as
Code:
java SochetEcho
Since pidof is not available, I have tried using pkill, but
Code:
pkill "java SocketEcho"
does not seem to be doing anything, so I have to bring the program to the foreground and ctrl-c. Simply using the ps command, cutting the PID and running it through kill is not really an acceptable solution as this does not carry over well to other scripts. I'm hoping somebody here has a better idea or knows what I am doing wrong. Thanks in advance.
 
Old 10-17-2008, 10:13 AM   #2
stuart_cherrington
Member
 
Registered: Aug 2008
Location: Get back in your Cube Unix Boy!
Distribution: rh5, oel5, debian etch, solaris
Posts: 228

Rep: Reputation: 36
OK, you can't enclose the pkill argument with "quotes". to use pkill to stop the "SocketEcho" script you need to to "pkill -f SocketEcho". Obviously as root, if you did a pkill java this would stop the last java process that ran, which may not be what you want. but as you'll probably only have one SocketEcho running this will pattern match for it and stop the ID.

As the /etc/init.d/SocketEcho stop, this will only work if the /etc/init.d/SocketEcho script contains a 'stop' flag. You can put my above pkill -f... command in the 'stop' section of the init.d script so the process can be stopped upon reboot.

Cheers,

Stuart
 
Old 10-17-2008, 10:26 AM   #3
Rocket2DMn
LQ Newbie
 
Registered: May 2007
Location: Pennsylvania
Distribution: Ubuntu, CentOS/RHEL, Solaris
Posts: 5

Original Poster
Rep: Reputation: 0
Ah, I thought I had tried that, but I guess I was doing something wrong before (or that I had misunderstood the -f option). I was skeptical of using quotes, but since my efforts to stop the program by passing SocketEcho had failed, that's all I had to run with.

That seems to have done the trick, thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
booting gentoo with / on reiser4 - Why won't any /etc/init.d scripts start? burninGpi Linux - General 2 08-31-2007 08:11 PM
custom init.d script will start but won't stop Qwerty9119 Red Hat 2 05-03-2007 01:51 PM
custom init.d script will start but won't stop Qwerty9119 Linux - General 2 05-03-2007 01:23 PM
Runlevel start/stop scripts vanalex Linux - General 0 01-27-2004 09:54 PM
Oracle 9i Start/Stop scripts vous Linux - Software 0 01-16-2004 02:59 AM


All times are GMT -5. The time now is 01:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration