Saturday, May 7, 2011

Manage services in Ubuntu

Start a service
(myServ is a service name)
sudo /etc/init.d/myServ start
sudo service myServ start
Stop a service
sudo /etc/init.d/myServ stop
sudo service myServ stop
Disable a service
Check if the service is handled by Upstart first by using
status myServ
If it returns the following message,
status: Unknown job: myServ
it's not handled by Upstart, disable it using
sudo update-rc.d myServ disable
For the service that is handled by Upstart, the output of the status command will be like:-
myServ start/running, process 989
If 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 enable
For Upstart managed services, undo what's been done above.


1 comment:

  1. Thanks for this helpful codes. this will now resolve my problem.