LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-25-2005, 06:25 AM   #1
shahrokhnikou
LQ Newbie
 
Registered: Jul 2005
Location: Finland
Posts: 11

Rep: Reputation: Disabled
Top initscript


Hi,

Howcan I write an script which has start/stop/status option including a program for example " Top" where I start as background process.

I tried this
==============================

#!/bin/bash
top
==========================
It's work but when I entered:

#!/bin/bash
top &

=======================
I got this error:

./test: line 3: top & : command not found
===================================

Overall my main question is how can I write script . I've an script for weblogic as " startWebLogic.sh" and I copied the script to /etc/init.d
and /etc/rc3.d and made an symbolic link like:
Code:
ln-s /opt/bea/domains/admin/startWebLogic.sh /etc/rc3.d/S90startWeblogic
but the problem is that I don't know how can I stop the program or restart it again.command kill it's not suitable to do that.
any help?
 
Old 10-25-2005, 07:38 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,765
Blog Entries: 54

Rep: Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976Reputation: 2976
Howcan I write an script which has start/stop/status option
Easiest way would be to copy and modify one from /etc/rc.d/init.d/.


./test: line 3: top & : command not found
First of all you have to make sure the binary is in the PATH (also "top" isn't a good example to daemonize).
If you have /etc/rc.d/init.d/functions, then it provides a function "daemon" to properly daemonize the service:

# See how were called:
case "$1" in
start) daemon /path/to/binary --any-args;;
stop) killproc /path/to/binary;;
restart) $0 stop; $0 start;;
*) echo help;;
esac


I've an script for weblogic as " startWebLogic.sh" and I copied the script to /etc/init.d
and /etc/rc3.d and made an symbolic link

Use "chkconfig --level 012456 service stop" and "chkconfig --level 3 service start" to set up starting/stopping a service properly.


but the problem is that I don't know how can I stop the program or restart it again.
If you want it to be compatible with how Weblogic does things I suggest you read Starting and Stopping WebLogic Servers (these are for 7.x).
 
Old 10-25-2005, 09:54 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
top won't run in the background.
it writes to a terminal device.

it doesn't make sense to run top like that.
 
  


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
Initscript shahrokhnikou Programming 8 10-24-2005 04:23 PM
Initscript shahrokhnikou Linux - General 3 10-24-2005 08:40 AM
My sound module (snd-mia) works, but without manually restarting the initscript... jacksonscottsly Linux - Hardware 0 07-31-2005 09:19 AM
Programs don't like "staying on top" or "always on top" -- any help? SBing Linux - Software 8 07-05-2004 05:41 AM
Top ? bohh Linux - Software 1 09-11-2003 09:57 PM


All times are GMT -5. The time now is 04:48 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