No se pudo encontrar el servicio de apagado de la unidad.

No se pudo encontrar el servicio de apagado de la unidad.

Estoy intentando configurar en un servidor Redhat, 2 servicios que inician una base de datos al inicio y la detienen al apagar, así que puse 2 archivos de /etc/systemd/systemla siguiente manera:

servicio.de.apagado:

[Unit]
Description=Shutdown database at shutdown
DefaultDependencies=no
Before=shutdown.target reboot.target halt.target

[Service]
Type=oneshot
ExecStart=/usr/DBA/shutdown.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

servicio de inicio:

[Unit]
Description=Start   database at startup after network becomes reachable
After=default.target

[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/usr/DBA/startup.sh
TimeoutStartSec=0

[Install]
WantedBy=default.target

luego hice estos comandos:

sudo systemctl daemon-reload
sudo systemctl enable startup.service
sudo systemctl enable shutdown.service
sudo systemctl start startup.service
sudo systemctl start shutdown.service

luego, cuando miro el estado, funcionan bien y se muestran activos y en ejecución. Luego reinicio el servidor y vuelvo a comprobar el estado, pero aparece esto:

[ec2-user@ip-10-193-117-56 system]$ sudo systemctl status shutdown.service
Unit shutdown.service could not be found.
[ec2-user@ip-10-193-117-56 system]$ sudo systemctl status startup.service
Unit startup.service could not be found.
[ec2-user@ip-10-193-117-56 system]$

Entonces no entiendo cuál es el problema. ¿Por qué no se encuentran los servicios después de reiniciar el servidor? se supone que deben habilitarse e iniciarse una vez, luego deberían iniciarse automáticamente.

Alguna idea ?

Aquí están ambos servicios dentro de la carpeta:

cd /etc/systemd/system
ls -l
-rw-rw-r--. 1 root root  246 Feb 22 16:02  startup.service
-rw-rw-r--. 1 root root  255 Feb 22 16:02  shutdown.service

Respuesta1

La respuesta a este problema es desactivar la función SELinux haciendo lo siguiente (desactivación permanente):

vi /etc/sysconfig/selinux

Luego cambie la directiva SELinux=enforcingaSELinux=disabled

Reinicie luego: sestatusahora debería mostrar que está deshabilitado.

información relacionada