Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I normally use service start/stop or initctl 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 example mysqld.

Currently what am doing is renaming /etc/init/mysql.conf to /etc/init/mysql.conf.bak but after reading a little about systemd I came to know that it provides enable & disable option for the above task.

So, is there something similar in ubuntu 12.04 with upstart.

share|improve this question
    
You say you are using systemd? I use it on my Fedora 17 computer. systemctl [enable|disable|is-enabled] mysqld.service –  BenjiWiebe Nov 2 '12 at 19:43
1  
@BenjiWiebe: No I am not using systemd. I am using upstart because systemd is not the default in ubuntu 12.04/12.10. –  Noob Nov 2 '12 at 19:45
1  
oh i see now... Not sure what i was thinking. –  BenjiWiebe Nov 2 '12 at 19:51
add comment

5 Answers

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

share|improve this answer
    
Is this still works with Ubuntu 12.04? –  RSK Feb 1 at 11:12
    
@RSK yes, why don't you just give it a try? –  warl0ck Feb 2 at 2:51
    
I tried and didn't worked for me. Lemme try again and will update you. –  RSK Feb 7 at 16:36
add comment

You can disable services by running the following command :

sudo update-rc.d -f <service name> disable
share|improve this answer
    
I don't have enough reputation to down vote this and doing so without an explanation would be impolite anyway, so then just a comment: The question by @Noob pertains to Ubuntu 12.04 which uses Upstart (/etc/init/*.conf configuration files) for most system daemons (as mentioned by @Noob) while your suggestion only works for daemons started using scripts in /etc/init.d/* (the old SysV style). Edit: For the record, warl0ck has the right answer (thanks!). –  xolox Aug 1 '13 at 16:47
1  
The 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. –  JustinC Oct 2 '13 at 15:01
add comment

@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).

[I don't have enough rep to comment above; mods wanting to clean this up may want to merge this answer?]

share|improve this answer
add comment

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.

share|improve this answer
1  
Yes '2' refer to the run-level. You can check your current run-level using who -r or runlevel. –  RanRag Nov 3 '12 at 6:42
    
That's true, who --runlevel. –  Emanuel Berg Nov 4 '12 at 3:22
1  
While 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). –  James O'Gorman Nov 5 '12 at 21:05
    
@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.) –  Emanuel Berg Nov 5 '12 at 22:31
    
@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 uses update-rc.d to manage this. RHEL (and derivatives) use chkconfig. –  James O'Gorman Nov 6 '12 at 18:49
add comment

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.

share|improve this answer
add comment

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.