Ubuntu12.04: How to disable a daemon process at startup
Solution 1
You can disable services by running the following command:
sudo update-rc.d -f <service name> disable
Man page excerpt:
When run with the disable [ S|2|3|4|5 ] options, update-rc.d modifies existing runlevel links for the script /etc/init.d/name by renaming start links to stop links with a sequence number equal to the difference of 100 minus the original sequence number.
Solution 2
The correct way to disable and upstart service, is create a XX.override file,
echo 'manual' > /etc/init/mysqld.override
That way the upstart service will not get started automatically
Solution 3
@warl0ck has it right; wanted to add that this information is documented quite well in the Upstart documentation: http://upstart.ubuntu.com/cookbook/#disabling-a-job-from-automatically-starting
Specifically:
With Upstart 1.3, you can make use of override files and the manual stanza to achieve the same result in a simpler manner [27]:
# echo "manual" >> /etc/init/myjob.override
Note that you could achieve the same effect by doing this:
# echo "manual" >> /etc/init/myjob.conf
However, using the override facility means you can leave the original job configuration file untouched.
To revert to the original behaviour, either delete or rename the override file (or remove the manual stanza from your ".conf" file).
Solution 4
There is also a nice piece of software to assist in this. Its called rcconf.
Just download it using:
sudo apt-get install rcconf
and use it with the command
rcconf
You get a nice (commandline) interface to disable/enable services.
Solution 5
Try navigate to /etc/rc2.d
and rename what you wish not to run at startup: change the (initial, capital) "S" into a "K" (e.g., S02mysql
to K02mysql
). If you change your mind, just reverse it. I think the 2 refers to runlevel, in what case 2 is the default, multiuser runlevel. Probably that's where you have most of the stuff for day-to-day computer use.
Edit: Read James O'Gorman's comment below.
RanRag
Updated on September 18, 2022Comments
-
RanRag over 1 year
I normally use
service start/stop
orinitctl start/stop
to start or stop a daemon process but now what I am looking for is to disable a daemon process from starting at startup examplemysqld
.Currently what am doing is renaming
/etc/init/mysql.conf
to/etc/init/mysql.conf.bak
but after reading a little aboutsystemd
I came to know that it providesenable & disable
option for the above task.So, is there something similar in ubuntu 12.04 with
upstart
.-
Admin over 11 yearsYou say you are using systemd? I use it on my Fedora 17 computer.
systemctl [enable|disable|is-enabled] mysqld.service
-
Admin over 11 years@BenjiWiebe: No I am not using systemd. I am using upstart because systemd is not the default in ubuntu 12.04/12.10.
-
-
RanRag over 11 yearsYes '2' refer to the run-level. You can check your current run-level using
who -r
orrunlevel
. -
Emanuel Berg over 11 yearsThat's true,
who --runlevel
. -
James O'Gorman over 11 yearsWhile this achieves what you want, it's technically the wrong thing to do. In SysV init terms, 'S' scripts are start scripts and 'K' are kill scripts - i.e. S are run in order at startup and K are run in order at shutdown (or changing to a lower runlevel).
-
Emanuel Berg over 11 years@JamesO'Gorman: Interesting, I'm on Debian, are you saying my "K scripts" are run at shutdown? Is there some letter that could be used to disable the script altogether, with no hazard whatsoever? (It is kind of practical to keep them in the same folder, should a new situation arise where you'd want them.)
-
James O'Gorman over 11 years@EmanuelBerg Yes,
init
will be running 'KXXscript stop' at shutdown. You should either remove the symlink or remove the execute bit from the real init script. I believe Debian usesupdate-rc.d
to manage this. RHEL (and derivatives) usechkconfig
. -
JustinC over 10 yearsThe question is about a hypothetical or in-general situation using mysql as a particular topical case. OP seemed at least partially aware of this answer, but it may serve posterity well to note that some useful packages don't and won't honor the upstart format (like webmin and many self-built from source packages around the time of comment). That means this method can be a valid partial answer for context, much like warl0ck and Mark's answers do to address the particular point of the hypothetical mysql service installed with a package manager.
-
RSK over 10 yearsIs this still works with
Ubuntu 12.04
? -
daisy over 10 years@RSK yes, why don't you just give it a try?
-
RSK over 10 yearsI tried and didn't worked for me. Lemme try again and will update you.
-
dannyman over 9 yearsThe -f flag is not needed.
-
Hi-Angel about 9 yearsNo, it doesn't work on Ubuntu-14.04.
-
m3nda almost 9 yearsThis is not included on the system, so install more stuff woudn't be the better answer.
-
Dmitry Koroliov over 8 years
@RSK yes, why don't you just give it a try?
I suppose, because it is very inconvenient to restart the system with "a try" to every advise from this page. -
Magico over 7 yearsbut really usefull :D
-
SineSwiper about 3 yearsThis is for init.d, not systemd, which most modern Linux systems use nowadays.