Linux Blog

Adding a service in Fedora

Filed under: Shell Script Sundays — at 2:08 pm on Sunday, July 6, 2008

This week on Shell Script Sundays I’ll show you how to add a service to Fedora. This is very useful if you don’t happen to use yum for every service you want to run, and xinetd doesn’t really work for you.

Firstly there are three main parts to a Fedora service script. Start, Stop and Restart. They are pretty much self explanatory, but you don’t have to worry about the restart action since all it does is stop’s and then starts the service.

Without further ado here is the script:

# Fedora-Service Update notification daemon
# Author:
# chkconfig:    1000 50 50
# description:  This is a test Fedora Service \
#               Second line of the fedora service template.
# processname:  FedoraTemplate
start() {
echo "Starting Fedora-Service"
stop() {
echo "Stopping Fedora-Service"
restart() {
case "$1" in
echo $"Usage: $0 {start|stop|restart}"
exit 1
exit $RETVAL

Now that you have a template for the script, you will want to modify it for your service. You need to keep the header at the top. This is how the Fedora Knows about your service. The three numbers indicate what order the scripts should start up and shut down in. The first seems to be a identification number and the other two are the startup and shutdown order. These can be adjusted depending on when you want the service to start up.Once you are done modifying the script put the script in /etc/init.d/

To make sure it works you can call it with service using the following actions:

service start
service stop
service restart

If all of the actions work, you are ready to add the service to the system. If you use the setup command as root it seems to do this step for you, but if you just want to add the service quickly without bothering to scramble through configuration menu’s you can do the following:

chkconfig --add [script name]

If you want the service to start automatically at boot up you can use ntsysv. For more information read my post on Managing Services on Fedora


Comment by Robbin

September 5, 2008 @ 10:01 am

As a side note – don’t forget to change your new services’ file permissions to 755 with

chmod 755

else you’d just get “no such service” errors, despite it shows the levels you’ve enabled it for with chkconfig –list

Comment by

September 5, 2008 @ 12:20 pm

@Robbin, good point! Forgot to mention that part :)

Comment by Kaolin Fire

October 8, 2008 @ 11:30 am

Thank you for this. :) courier-authlib’s been dropped from fedora but I’m pretty locked into it, and it’s nice to be able to set it up with services, still.

Comment by

October 9, 2008 @ 9:13 am

Thanks for taking the time to comment. You are welcome, thats what this blog is here for. I’ve never used courier-authlib and cannot say I know what it is.

Pingback by The Linux Blog » Using a custom Tomcat on Fedora

November 12, 2008 @ 10:22 am

[…] post is somewhat related to: my Adding a service on Fedora post except this one is more specific to Tomcat. If you’d like more information on adding […]

Comment by No.9

September 22, 2009 @ 12:22 am

Thanks a lot.
And I found it’s needed to chmod +x to the script.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>