Apr 072011
 

If you use Tomcat occasionally you may want the package installed but not have it startup at boot time.
These notes are for Debian 6.0 (Squeeze) and the supplied Tomcat 6 package.

Tomcat can simply be removed between uses with apt-get or aptitude. But this is time consuming and can be error prone if one accidentally purges and removes all the carefully crafted config files.

Many Debian packages use an “enabled=1” setting in /etc/default/packageName to control startup but even though some great improvements have been made in the Tomcat startup scripts this was not one of them.

Check the run level config:

# ls -l /etc/rc?.d/*tomcat*
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc0.d/K01tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc1.d/K01tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc2.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc3.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc4.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc5.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:42 /etc/rc6.d/K01tomcat6 -> ../init.d/tomcat6

To disable run level startup:

# update-rc.d -f tomcat6 remove
update-rc.d: using dependency based boot sequencing

Confirmation check:

# ls -l /etc/rc?.d/*tomcat*
ls: cannot access /etc/rc?.d/*tomcat*: No such file or directory

Yay!

Now we can manually start/stop Tomcat at will:

# /etc/init.d/tomcat6 start
# /etc/init.d/tomcat6 stop
# /etc/init.d/tomcat6 restart

To re-enable run level startup (as per .deb package postinst):

# update-rc.d tomcat6 defaults 92 08
update-rc.d: using dependency based boot sequencing
 
# ls -l /etc/rc?.d/*tomcat*
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc0.d/K01tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc1.d/K01tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc2.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc3.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc4.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc5.d/S20tomcat6 -> ../init.d/tomcat6
lrwxrwxrwx 1 root root 17 Apr  6 00:45 /etc/rc6.d/K01tomcat6 -> ../init.d/tomcat6

It’s back!

The same should be possible for other services like mysql and apache2:

update-rc.d -f mysql remove
update-rc.d -f mysql-ndb remove
update-rc.d -f mysql-ndb-mgm remove
update-rc.d -f apache2 remove

Note: however that these changes are not completely permanent. For example after apache gets updated it will re-instate it’s start-up rules.

[suffusion-the-author display='first-name'] [suffusion-the-author display='last-name']:


Thank you for visiting.
Do look around.
Do leave a comment.

 Leave a Reply

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

(required)

(required)