LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-16-2001, 04:22 PM   #1
sophia liu
LQ Newbie
 
Registered: Jul 2001
Location: California, USA
Distribution: RedHat
Posts: 2

Rep: Reputation: 0
system services


I have an application that needs to be automatically started after system restart. How do I add the application as a system service?

Thanks in advance,
Sophia
 
Old 07-16-2001, 04:35 PM   #2
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
What distro are you using, the location of the startup script you need to edit are distribution dependent. If you were on slackware then you would edit /etc/rc.d/rc.local but yours may well be in a different place.

Post your distro and I'm positive someone will be able to tell you the file.

HTH

Jamie...
 
Old 07-16-2001, 07:24 PM   #3
sophia liu
LQ Newbie
 
Registered: Jul 2001
Location: California, USA
Distribution: RedHat
Posts: 2

Original Poster
Rep: Reputation: 0
The distro is RedHat.

Thanks,
Sophia
 
Old 07-18-2001, 08:01 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
ok, RH. It depends on if an app needs starting at a specific time, or it just needs starting.

If it just needs starting, add it to the end of /etc/rc.d/rc.local ,else if it needs starting at a specific point, like after networking comes up, but before some other app starts, its best to use good ol SYSV stylee, which startfiles are located at /etc/rc.d/init.d and then linked to the runlevel u want it to start in, say runlevel 3, then its linked to /etc/rc.d/rc3.d.
It needs a proper executable startscript which is easy to make. Save this script (no indentation, I know that sux0rz) as the name of the daemon to start, Ill call it myApp for now, and make it executable by root:

|---cut_here--->
#!/bin/sh
. /etc/rc.d/init.d/functions
DAEMON=/usr/local/bin/myApp
CONFIG=/etc/myApp.conf
XPARMS="-d -v"
case "$1" in
start)
daemon $DAEMON $CONFIG $XPARMS
touch /var/lock/subsys/myApp
echo "myApp started"
;;
stop
killproc myApp
rm -f /var/lock/subsys/myApp
echo "myApp stopped"
;;
status)
status myApp
reload|restart)
$0 stop
$0 start
;;
*)
echo "myApp [start|stop|reload|restart|status]"
exit 1
esac
<---cut_here---|

now decide on the runlevels and the sequence number u want it to start as. in each runlevel the capital K denotes services that are stopped on entering the runlevel, and the S marks services that are started, in order 1-99.

Now we'll (soft/force)link it to start in runlevel 3 as the 10th entry:
ln -sf /etc/rc.d/init.d/myApp /etc/rc.d/rc3.d/S10myApp

Now we'll (soft/force)link it to stop properly in runlevels 0 and 6 (halt and reboot level as the 1th entry:
ln -sf /etc/rc.d/init.d/myApp /etc/rc.d/rc0.d/K01myApp
ln -sf /etc/rc.d/init.d/myApp /etc/rc.d/rc6.d/K01myApp

Done.
Start it manually as "/etc/rc.d/init.d/myApp start" or watch it come up on reboot in the runlevel.

HTH
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
system services TranceDude Linux - Software 1 08-12-2005 01:42 PM
system settings >services problems glenfiddick Linux - Networking 1 07-01-2005 09:14 AM
List of System Services and their descriptions demerson3 Linux - Newbie 1 09-12-2004 02:27 AM
Where to find system services information joeyBig Linux - General 1 07-24-2004 08:52 AM
System services ANU Linux - Security 7 09-17-2003 12:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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