150

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>
Marco Ceppi
  • 48,827

5 Answers5

129

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

Zanna
  • 72,312
55

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
Marco Ceppi
  • 48,827
jokerulez
  • 551
10

Try this:

apt-get install chkconfig

This works, at least of as Ubuntu 12.04 release.

Eliah Kagan
  • 119,640
10

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.

maco
  • 16,132
6

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.