Diferenças entre edições de "UBUNTU manage services"

De Wiki do Bernardino
Ir para: navegação, pesquisa
(Enable service)
Linha 32: Linha 32:
  
 
  sudo rm /etc/init/mysql.override
 
  sudo rm /etc/init/mysql.override
 +
 +
 +
==SYSTEMD==
 +
 +
Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following:
 +
 +
systemctl start SERVICE - Use it to start a service. Does not persist after reboot
 +
 +
systemctl stop SERVICE - Use it to stop a service. Does not persist after reboot
 +
 +
systemctl restart SERVICE - Use it to restart a service
 +
 +
systemctl reload SERVICE - If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.
 +
 +
systemctl status SERVICE - Shows the status of a service. Tells whether a service is currently running.
 +
 +
systemctl enable SERVICE - Turns the service on, on the next reboot or on the next start event. It persists after reboot.
 +
 +
systemctl disable SERVICE - Turns the service off on the next reboot or on the next stop event. It persists after reboot.
 +
 +
systemctl is-enabled SERVICE - Check if a service is currently configured to start or not on the next reboot.
 +
 +
systemctl is-active SERVICE - Check if a service is currently active.
 +
 +
systemctl show SERVICE - Show all the information about the service.

Revisão das 12h25min de 15 de setembro de 2016

Disable service

Disable autostart for a service without uninstalling

update.rc

The disable|enable API is not stable and might change in the future. I suggest you use the following command to remove all the symlinks in /etc/rc?.d/:

update-rc.d -f tomcat remove


upstart

For upstart jobs, you need to disable service like this (e.g. mysql):

$ sudo -s
# echo "manual" > /etc/init/mysql.override


Enable service

Enable a service to autostart

update.rc

Create a service with defaults, foobar example

update-rc.d foobar defaults


upstart

If you put the MySQL service into manual mode and want enable again you can simply do

sudo rm /etc/init/mysql.override


SYSTEMD

Starting with Ubuntu 15.04, Upstart will be deprecated in favor of Systemd. With Systemd to manage the services we can do the following:

systemctl start SERVICE - Use it to start a service. Does not persist after reboot

systemctl stop SERVICE - Use it to stop a service. Does not persist after reboot

systemctl restart SERVICE - Use it to restart a service

systemctl reload SERVICE - If the service supports it, it will reload the config files related to it without interrupting any process that is using the service.

systemctl status SERVICE - Shows the status of a service. Tells whether a service is currently running.

systemctl enable SERVICE - Turns the service on, on the next reboot or on the next start event. It persists after reboot.

systemctl disable SERVICE - Turns the service off on the next reboot or on the next stop event. It persists after reboot.

systemctl is-enabled SERVICE - Check if a service is currently configured to start or not on the next reboot.

systemctl is-active SERVICE - Check if a service is currently active.

systemctl show SERVICE - Show all the information about the service.