(myServ is a service name)
sudo /etc/init.d/myServ startor
sudo service myServ startStop a service
sudo /etc/init.d/myServ stopor
sudo service myServ stopDisable a service
Check if the service is handled by Upstart first by using
status myServIf it returns the following message,
status: Unknown job: myServit's not handled by Upstart, disable it using
sudo update-rc.d myServ disableFor the service that is handled by Upstart, the output of the status command will be like:-
myServ start/running, process 989If that's the case, then the service can be disabled by doing one of the following
- Open the Upstart job definition file (e.g. /etc/init/myServ.conf) and then comment out the "start on" line by putting a "#" in front of it.
- Add a special keyword "manual" to the job definition file by just using the command "echo"
echo manual | sudo tee -a /etc/init/myServ.conf
Enable a service
For non-Upstart managed services, use
sudo update-rc.d myServ enableFor Upstart managed services, undo what's been done above.
Refs:
http://lwn.net/Articles/382853/
http://askubuntu.com/questions/19320/whats-the-recommend-way-to-enable-disable-services
Thanks for this helpful codes. this will now resolve my problem.
ReplyDelete