![El comando de servicio no reconoce el archivo de servicio. RHEL6.9](https://rvso.com/image/154482/El%20comando%20de%20servicio%20no%20reconoce%20el%20archivo%20de%20servicio.%20RHEL6.9.png)
Estoy usando rhel6.9
y copié mi archivo de servicio en las carpetas /etc/systemd/system
y /usr/lib/systemd/system/
. He configurado servicios usando systemctl
antes, pero nunca lo he probado con el service
comando de la vieja escuela.
Ahora service mytest start
no funciona, dice que es un servicio no reconocido. En systemctl
you run daemon-reload
, pero ¿cómo hago eso service
?
Respuesta1
service
es un comando de "alto nivel" utilizado para iniciar, reiniciar, detener y estado
de servicios en diferentes Unixes y Linux. Dependiendo del administrador de servicios de "nivel inferior", el servicio se redirecciona en diferentes archivos binarios.Por ejemplo, en CentOS 7 redirige a
systemctl
, mientras que en CentOS 6 llama directamente al/etc/init.d
script relativo. Por otro lado, en versiones anteriores de Ubuntu redirige al advenedizo.El servicio es adecuado para la gestión de servicios básicos, mientras que las llamadas directas
systemctl
dan mayores opciones de control.
En RHEL6 primero agrega el servicio:
chkconfig --add SERVICE
luego para habilitar o deshabilitar:
chkconfig SERVICE on
chkconfig SERVICE off
Compruebe si el servicio está habilitado:
chkconfig SERVICE --list
También puede en RHEL7 y versiones superiores activar el servicio de esta manera para comenzar en el siguiente inicio u otro activador:
systemctl enable SERVICE
Tenga en cuenta que todas las versiones recientes de systemctl
asumen el ".servicio" si se deja.
/etc/systemd/system/lircmd.service
Se convierte en:
systemctl enable lircmd
También Systemd
trae todo lo que solías hacer con chkconfig
y service
bajo un solo comando, systemctl
por lo que generalmente lo encuentro más fácil de manejar a largo plazo.
Ver también man update-rc.d
:
update-rc.d
runlevel
requiere que se proporcione dependencia e información en el init.d
encabezado del comentario LSB del script de todos init.d
los scripts.
Como aquí:
Agregue un bloque como este en el init.d
script:
### BEGIN INIT INFO
# Provides: scriptname
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
https://wiki.debian.org/LSBInitScripts
El comando de servicio es un script contenedor que permite a los administradores del sistema iniciar, detener y verificar el estado de los servicios sin preocuparse demasiado por el init
sistema real que se está utilizando. Antes de la introducción de systemd, era un contenedor para /etc/init.d
scripts y comandos de Upstart initctl
, y ahora es un contenedor para estos dos y también para systemctl.
man service
:
service(8) System Manager's Manual service(8)
NAME
service - run a System V init script
SYNOPSIS
service SCRIPT COMMAND [OPTIONS]
service --status-all
service --help | -h | --version
DESCRIPTION
service runs a System V init script, systemd unit, or upstart job in as predictable an environment as possible, removing most environment variables and with the current working directory set to /.
The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT, or the name of a systemd unit, or the name of an upstart job in /etc/init. The existence of a systemd unit or upstart job of the same name
as a script in /etc/init.d will cause the unit/job to take precedence over the init.d script. The supported values of COMMAND depend on the invoked script. service passes COMMAND and OPTIONS to the init script unmodified.
For systemd units or upstart jobs, start, stop, status, and reload are passed through to their systemctl/initctl equivalents. For upstart jobs, restart will call the upstart 'stop' for the job, followed immediately by the
'start', and will exit with the return code of the start command.
All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. This option has no effect
on upstart jobs.
service --status-all runs all init scripts, in alphabetical order, with the status command. The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a 'status' command. This
option only calls status for sysvinit jobs; upstart jobs can be queried in a similar manner with initctl list.
EXIT CODES
service calls the init script and returns the status returned by it.
FILES
/etc/init.d
The directory containing System V init scripts.
/etc/init
The directory containing upstart jobs.
/{lib,run,etc}/systemd/system
The directories containing systemd units.
ENVIRONMENT
LANG, LANGUAGE, LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT, LC_IDENTIFICATION, LC_ALL, TERM, PATH
The only environment variables passed to the init scripts.
SEE ALSO
/etc/init.d/skeleton,
update-rc.d(8),
init(8),
invoke-rc.d(8).
systemctl(1).
initctl(8).
Ver también:
administrar-servicios-usando-systemd-y-systemctl-en-linux/
Fuentes:
https://askubuntu.com/questions/903354/difference-between-systemctl-and-service-commands
https://stackoverflow.com/questions/43537851/difference-between-systemctl-and-service-command
http://www.safdar.com/how-to/linux-services-systemctl-systemd-vs-service-sysvinit.html
scripts de servicio versus systemctl: cuál usar