LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-04-2008, 01:34 AM   #1
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Rep: Reputation: 16
Implement status for my init.d script


Hi All,

here is is my init.d script for a daemon

Code:
 

#!/bin/sh
echo "This is a init script for my daemon"

start() {
            # Load some gh2 kernel modules
            if [ -f /home/try/test1d ] ; then
                   ./test1d
		   
		   echo "daemon started started"
             fi

           
}
stop() {
	
        echo -n "daemon stoopped: "
	killall -SIGINT test1d       
        echo "OK"
}
status() {
	
}
restart() {
        stop
        start
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
 status)
	status
	;;
  restart|reload)
        restart
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?

#
How do I implement Status for th same daemon.


Thanks in advance ....


-Ashok Athukuri
 
Old 07-04-2008, 06:24 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
The best way is to look at how other init scripts do it (please fill in your distro info in your profile) but somethin like
Code:
status) echo -en "test1d: "; /usr/bin/pgrep -lf '/home/try/test1d' >/dev/null 2>&1 && running || echo gone;;
could work. It relies on 'pgrep' and on you not using "./test1d" but "/home/try/test1d" to start your process. Also note that the she-bang line must be the first line of your script (no newlines above it) and if this is about kernel modules (as one of your comments suggest) then there are other ways to load those, unless you require more finegrained control over it wrt timing.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
clurgmgrd keeps runnings custom init.d script's status every 30 seconds or so Qwerty9119 Red Hat 1 10-17-2007 08:41 AM
how to implement history in myown script sudevank Linux - Software 3 08-01-2007 08:57 AM
Slack equivalent of status, daemon and killproc from RH init.d/functions MQMan Slackware 1 07-26-2007 04:31 PM
how implement battery status on acer aspire....kernel 2.6.15.6 sarajevo Debian 3 03-24-2006 10:06 AM
how to implement an endless loop in a rc startup script garba Linux - General 6 05-03-2005 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:55 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
Open Source Consulting | Domain Registration