GNU/Linux >> Tutoriales Linux >  >> Ubuntu

¿No puede obtener el servicio Noip2 para iniciar en el arranque?

Esta pregunta ya tiene respuestas aquí :¿Cómo configuro No-IP como un servicio adecuado?

(2 respuestas)
Cerrado hace 2 años.

He instalado ddns dinámicos sin IP siguiendo esta guía:
https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client/

Obtengo el servicio funcionando

sudo /usr/local/bin/noip2

Sin embargo, quiero que el servicio se inicie en el arranque, intenté agregar el siguiente script a /etc/init.d/noip2.sh

#######################################################
#! /bin/sh
# . /etc/rc.d/init.d/functions  # uncomment/modify for your killproc
case "$1" in
    start)
    echo "Starting noip2."
    /usr/local/bin/noip2
    ;;
    stop)
    echo -n "Shutting down noip2."
    killproc -TERM /usr/local/bin/noip2
    ;;
    *)
    echo "Usage: $0 {start|stop}"
    exit 1
esac
exit 0
#######################################################

Seguido por:

sudo chmod +x /etc/init.d/noip2.sh
sudo update-rc.d noip2.sh defaults

Ahora debería poder iniciar el servicio con

sudo service noip2 start

Pero yo no. Cuando ejecuto journalctl -xe Obtengo lo siguiente:

-- Unit noip2.service has begun starting up.
Nov 03 12:36:11 media systemd[3111]: noip2.service: Failed to execute command: Exec format error
Nov 03 12:36:11 media systemd[3111]: noip2.service: Failed at step EXEC spawning /etc/init.d/noip2.sh: Exec format error
-- Subject: Process /etc/init.d/noip2.sh could not be executed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The process /etc/init.d/noip2.sh could not be executed and failed.
--
-- The error number returned by this process is 8.
Nov 03 12:36:11 media systemd[1]: noip2.service: Control process exited, code=exited status=203
Nov 03 12:36:11 media systemd[1]: noip2.service: Failed with result 'exit-code'.
Nov 03 12:36:11 media systemd[1]: Failed to start noip2.service.
-- Subject: Unit noip2.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support

Información actualizada para el usuario PerDuck:
Recibo los siguientes errores al intentar su solución... 🙁
Intenté agregar

RestartSec=30

Al menos sigue intentándolo ahora pero todavía no arranca. Todavía puedo iniciarlo con sudo /usr/local/bin/noip2

Los errores:

Nov 03 23:26:42 media systemd[1]: noip2.service: Service hold-off time over, scheduling restart.
Nov 03 23:26:42 media systemd[1]: noip2.service: Scheduled restart job, restart counter is at 5.
Nov 03 23:26:42 media systemd[1]: Stopped noip2 service.
Nov 03 23:26:42 media systemd[1]: noip2.service: Start request repeated too quickly.
Nov 03 23:26:42 media systemd[1]: noip2.service: Failed with result 'start-limit-hit'.
Nov 03 23:26:42 media systemd[1]: Failed to start noip2 service.

Respuesta aceptada:

Desde Ubuntu 15.04, la forma estándar de controlar los procesos en segundo plano (y mucho, mucho más) es systemd .
Sugiero cambiar de su init.d secuencia de comandos a un systemd unidad :

Cree el archivo /etc/systemd/system/noip2.service con el siguiente contenido (y suelte su init.d guiones):

[Unit]
Description=noip2 service

[Service]
Type=forking
ExecStart=/usr/local/bin/noip2
Restart=always

[Install]
WantedBy=default.target

Entonces emita

sudo systemctl daemon-reload

para hacer systemd consciente de la nueva unidad (systemd almacena en caché los archivos de la unidad y este comando hace que systemd reconsidere su caché).

Ahora puede intentar iniciar y detener su unidad y ver su estado:

sudo systemctl status noip2
sudo systemctl start  noip2
sudo systemctl status noip2
sudo systemctl stop   noip2
sudo systemctl status noip2

Para que la unidad se inicie en el momento del arranque, debe habilitar es:

sudo systemctl enable noip2

Para deshabilitar el inicio automático en el momento del arranque, debe deshabilitar la unidad:

sudo systemctl disable noip2

La mayoría de las veces cinco comandos son suficientes para controlar el comportamiento de una unidad:

systemctl start   $unit   # starts a unit NOW
systemctl stop    $unit   # stops a unit NOW
systemctl status  $unit   # shows status
systemctl enable  $unit   # starts a unit at boot time (but not NOW)
systemctl disable $unit   # stops autostart (but doesn't stop the unit NOW)

También puede habilitar el inicio automático e iniciar la unidad inmediatamente o deshabilitar el inicio automático y detenerlo de inmediato:

systemctl enable  --now $unit   # enable and start in one go
systemctl disable --now $unit   # disable and stop in one go

Actualizar

Algunas investigaciones revelaron el noip2 se ejecuta como un demonio , es decir, cuando lo inicia, crea otro proceso que se ejecuta en segundo plano (llamado bifurcación ) y el proceso en primer plano regresa inmediatamente (sale). Es por eso que el script init.d y la unidad systemd fallaron:iniciaron noip2 sólo para ver que sale inmediatamente. Por lo tanto, systemd intentó reiniciarlo una y otra vez sin éxito. (De forma predeterminada, systemd reinicia un proceso como máximo 5 veces en 10 segundos antes de darse por vencido y dejarlo en un estado fallido).

Relacionado:¿Mover la carpeta de inicio a una nueva instalación de Ubuntu?

Para decirle a systemd que la unidad es del tipo bifurcación añade la línea

Type=forking

al [Service] sección como acabo de hacer en el fragmento anterior. Esto le dice a systemd que espera el proceso principal para regresar de inmediato, pero en su lugar observe el proceso generado (bifurcado) por noip2 .


Ubuntu
  1. ¿Cómo iniciar el servidor Vnc en el arranque?

  2. ¿Se agotó el tiempo de espera del servicio Systemctl durante el inicio?

  3. ¿Error al iniciar Thesql Community Server (5.7)?

  4. ¿No puedo obtener una salida Telnet Localhost 25, Ehlo Localhost de 250-auth?

  5. ¿No puede hacer que 3d Vision funcione?

Cómo iniciar el servicio en el arranque con RHEL 8 / CentOS 8 Linux

Cómo iniciar el servicio al arrancar en Ubuntu 22.04

Cómo iniciar, detener o reiniciar Apache

Cómo iniciar, detener o reiniciar Nginx

Cómo iniciar, detener o reiniciar servicios en Ubuntu 20.04 LTS

Cómo iniciar, detener o reiniciar servicios en Ubuntu