Another very quick post for all you aspiring Ubuntu server admins out there. I am not sure how I got along as far as I did without knowing how to easily add a service to the boot time start list or remove it from said list. I already knew how to manually start or stop a service on a running server but I am including those commands just to make this post a bit more complete. This is a short and sweet post (really for my own uses) with an assumption you know more or less what we are trying to accomplish and just need the commands to do it.

I ran across an acute need for this recently on my backup server. I am using varnish as a caching layer on my primary server (the one this blog is hosted on) and also have it installed on my backup server. I don’t want my sites to be available on the backup server when it is just sitting there. But I want it to be a “warm” backup server (i.e. almost ready to go live/production with minimal flipping of switches). To that end all of my sites and databases are already there and configured and actually running. That means Apache is up and running as is MySQL and I have a script to quickly restore a recent backup of the database, see that post here:

Bash Script for Quick Restore of Multiple Databases

That means if someone hits my backup server’s public IP, they are going to see one of the sites. This is bad from an SEO perspective because if google somehow indexes the sites running on the backup server and realizes they are duplicate content it will hurt page rank. So how do I keep the server “warm” without allowing public access to the sites? Simple, turn varnish off. Varnish is the front caching layer and sits in front of Apache, so if it is turned off, no sites… Varnish is set to start at boot automatically though, hence I needed commands to quickly enable and disable varnish and also add or remove it to the list of services that start during server bootup. Here we go…

Start and stop a service

service varnish start
service varnish stop

Remove a service from autostart at boot time:

update-rc.d -f varnish remove

Add a service to autostart at boot time:

update-rc.d varnish defaults

That’s it. Cheers!


1 of 1

This post has no comments. Be the first to leave one!

Leave a Reply