Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've become very accustomed to managing service startups on Redhat/RHEL platforms using chkconfig though that doesn't appear to be the Debian/Ubuntu way - How do I update runlevel information for system services on Ubuntu?

Ultimately looking for the equivalents of:

chkconfig --add <service>
chkconfig --level 345 <service> on
chkconfig --del <service>
share|improve this question

5 Answers 5

up vote 65 down vote accepted

The equivalent to chkconfig is update-rc.d

The equivalents you seek are

update-rc.d <service> defaults
update-rc.d <service> start 20 3 4 5
update-rc.d -f <service>  remove

See this useful page for more information or check out man update-rc.d

share|improve this answer
3  
update-rc.d is only meant to be used in packaging scripts, not by humans. It also is for init scripts, which Ubuntu doesn't use. Ubuntu uses Upstart. –  maco Aug 14 '10 at 17:22
7  
"Please note that this program was designed for use in package maintainer scripts and, accordingly, has only the very limited functionality required by such scripts. System administrators are not encouraged to use update-rc.d to manage runlevels. They should edit the links directly or use runlevel editors such as sysv-rc-conf and bum instead." From the manpage: manpages.ubuntu.com/manpages/hardy/man8/update-rc.d.8.html –  maco Aug 14 '10 at 20:12
2  
I'm accepting this answer because the updated man pages have removed that warning. manpages.ubuntu.com/manpages/lucid/man8/update-rc.d.8.html –  Marco Ceppi Aug 15 '10 at 19:16
2  
Which still doesn't change the fact that Ubuntu doesn't even use SysV init scripts nowadays and update-rc.d is only for them. –  maco Aug 15 '10 at 23:49

Best alternative IMHO is sysv-rc-conf To install just need to run the command:

sudo apt-get install sysv-rc-conf

Once installed run the command:

sudo sysv-rc-conf

You can check or uncheck the options to start a service on any level of execution and may even stop or start the services from this console. It is an indispensable tool to enable or disable applications on an permanently way to boot your ubuntu If you need a quick change, then you can use the CLI interface:

For example to stop ssh at levels 3 and 5 of execution:

sysv-rc-conf-off level 35 ssh

Atd to start in runlevels 2,3,4 and 5:

sysv-rc-conf on atd

If you want to know more:

man sysv-rc-conf
share|improve this answer
    
This is exactly what I needed, except I did sysv-rc-conf apache2 on / sysv-rc-conf apache2 off etc. –  Adam K Dean Jan 15 at 14:47

Right now, there is no equivalent on a stable release for doing things with Upstart scripts. Jacob Peddicord wrote jobservice (backend daemon) and jobs-admin (GTK+ GUI that talks to it) for his Google Summer of Code project. Lucid packages are in his PPA. They also exist in Universe in Maverick. There is no command line front-end for jobservice yet, just jobs-admin.

share|improve this answer

Try this:

apt-get install chkconfig

This works, at least of as Ubuntu 12.04 release.

share|improve this answer
2  
Doesn't work on 12.10 –  ruslan Feb 22 '13 at 20:56
    
have 12.04, and apt-get install chkconfig gives: "E: Package 'chkconfig' has no installation candidate". Whats in your /etc/apt/sources.list file? –  John Little Mar 17 at 10:22

Lets walk from ZERO to Goal - how to do it with step by step.

Step 1: lets write a hello world

cat >> /var/tmp/python/server.py <<\EOF
#/usr/bin/python
import time
while True:
  print "hello> YES Bello"
  time.sleep(30)

EOF

Step 2: lets make our hello world application server.py automated

cat >> /var/tmp/myserver.sh <<\EOF
#!/bin/sh
script='/var/tmp/python/server.py'
export DISPLAY=:0.0 && /usr/bin/python $script &

EOF
chmod +x /var/tmp/myserver.sh

cat >> /etc/init.d/myserver <<\EOF

#! /bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/var/tmp/myserver.sh
PIDFILE=/var/run/myserver.pid

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
  start)
     log_daemon_msg "Starting feedparser"
     start_daemon -p $PIDFILE $DAEMON
     log_end_msg $?
   ;;
  stop)
     log_daemon_msg "Stopping feedparser"
     killproc -p $PIDFILE $DAEMON
     PID=`ps x |grep server.py | head -1 | awk '{print $1}'`
     kill -9 $PID       
     log_end_msg $?
   ;;
  force-reload|restart)
     $0 stop
     $0 start
   ;;
  status)
     status_of_proc -p $PIDFILE $DAEMON atd && exit 0 || exit $?
   ;;
 *)
   echo "Usage: /etc/init.d/atd {start|stop|restart|force-reload|status}"
   exit 1
  ;;
esac

exit 0


EOF
chmod +x /etc/init.d/myserver
chmod -R 777 /etc/init.d/myserver

Step 3:

$ update-rc.d myserver defaults
update-rc.d: warning: /etc/init.d/myserver missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
 Adding system startup for /etc/init.d/myserver ...
   /etc/rc0.d/K20myserver -> ../init.d/myserver
   /etc/rc1.d/K20myserver -> ../init.d/myserver
   /etc/rc6.d/K20myserver -> ../init.d/myserver
   /etc/rc2.d/S20myserver -> ../init.d/myserver
   /etc/rc3.d/S20myserver -> ../init.d/myserver
   /etc/rc4.d/S20myserver -> ../init.d/myserver
   /etc/rc5.d/S20myserver -> ../init.d/myserver
  • So in step 3, the system on boot, will automatically execute the server.py as daemon and make it easy to automate

Hope it helped.

share|improve this answer
    
+1: Very useful answer but I think it has the wrong question attached to it. –  Claris Feb 27 at 17:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.