Diferencias
Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
| doc:tec:sis:gnu:hora:inicio [2025/12/19 10:46] – fepg | doc:tec:sis:gnu:hora:inicio [2025/12/19 10:51] (actual) – fepg | ||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== [Linux] Configurar la hora ====== | ====== [Linux] Configurar la hora ====== | ||
| - | Usar systemd‑timesyncd | + | ===== Sincronizar hora con NTP o systemd‑timesyncd |
| - | Debian | + | |
| - | | + | |
| - | Instalar (si no existe): | + | Para sincronizar la hora con NTP en Debian 13 lo habitual es usar **systemd‑timesyncd** a través de `timedatectl`, |
| - | bash | + | **Comprobar estado actual** |
| - | sudo apt update | + | |
| - | sudo apt install systemd-timesyncd | + | |
| - | Habilitar y arrancar: | + | |
| - | bash | + | * Ver estado de hora, NTP y zona horaria: < |
| - | sudo systemctl enable --now systemd-timesyncd.service | + | |
| - | Activar la sincronización | + | |
| - | bash | + | timedatectl |
| - | sudo timedatectl | + | |
| - | Verificar: | + | </ |
| + | - System clock synchronized: | ||
| + | - NTP service: debería decir active si se usa systemd‑timesyncd u otro cliente NTP integrado.[7][3] | ||
| - | bash | + | **Usar systemd‑timesyncd** |
| - | timedatectl status | + | |
| - | systemctl status systemd-timesyncd.service | + | Debian moderno suele integrar `systemd‑timesyncd` como cliente SNTP ligero, pero puede no venir instalado o habilitado por defecto.[4][6][7] |
| - | Si el servicio aparece como active (running) y NTP service: active, el reloj se sincroniza con servidores NTP configurados en systemd‑timesyncd | + | |
| + | - 1. Instalar (si no existe): < | ||
| + | |||
| + | # apt update | ||
| + | # apt install systemd-timesyncd | ||
| + | |||
| + | </ | ||
| + | - 2. Habilitar y arrancar: | ||
| + | | ||
| + | sudo systemctl enable --now systemd-timesyncd.service | ||
| + | ``` | ||
| + | - 3. Activar la sincronización NTP en systemd: | ||
| + | | ||
| + | sudo timedatectl set-ntp true | ||
| + | ``` | ||
| + | - 4. Verificar: | ||
| + | ```bash | ||
| + | | ||
| + | | ||
| + | ``` | ||
| + | Si el servicio aparece como `active (running)` y `NTP service: active`, el reloj se sincroniza con servidores NTP configurados en `systemd‑timesyncd`.[1][3][7] | ||
| + | |||
| + | **Configurar servidores NTP en systemd‑timesyncd** | ||
| + | |||
| + | - Editar el archivo de configuración: | ||
| + | ```bash | ||
| + | sudo nano / | ||
| + | ``` | ||
| + | - En la sección `[Time]`, define tus servidores: | ||
| + | ```ini | ||
| + | [Time] | ||
| + | NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org | ||
| + | FallbackNTP=2.debian.pool.ntp.org 3.debian.pool.ntp.org | ||
| + | ``` | ||
| + | - Aplicar cambios: | ||
| + | ```bash | ||
| + | sudo systemctl restart systemd-timesyncd.service | ||
| + | sudo timedatectl status | ||
| + | ``` | ||
| + | En entornos con servidor NTP interno pon la IP o nombre de ese servidor en `NTP=` y deja `FallbackNTP` con servidores públicos.[9][1][3] | ||
| + | |||
| + | **Usar un demonio NTP completo (ntp o chrony)** | ||
| + | |||
| + | Si necesitas más precisión, estadísticas o servir tiempo a otros equipos, conviene instalar un cliente/ | ||
| + | |||
| + | - 1. Instalar `ntp` (ejemplo): | ||
| + | | ||
| + | sudo apt update | ||
| + | sudo apt install ntp | ||
| + | ``` | ||
| + | O bien `chrony`: | ||
| + | | ||
| + | sudo apt install chrony | ||
| + | ``` | ||
| + | - 2. Desactivar la sincronización de systemd‑timesyncd para evitar conflictos: | ||
| + | | ||
| + | sudo timedatectl set-ntp false | ||
| + | sudo systemctl disable --now systemd-timesyncd.service | ||
| + | ``` | ||
| + | - 3. Configurar servidores en: | ||
| + | - `/ | ||
| + | - `/ | ||
| + | | ||
| + | | ||
| + | sudo systemctl restart ntp | ||
| + | # o | ||
| + | sudo systemctl restart chrony | ||
| + | ``` | ||
| + | `ntp` y `chrony` proporcionan más opciones de ajuste fino, pero para la mayoría de escritorios y servidores simples basta con systemd‑timesyncd.[3][6][7] | ||
| + | |||
| + | **Forzar y verificar sincronización** | ||
| + | |||
| + | - Forzar actualización rápida (útil después de cambiar servidores): | ||
| + | - Con systemd‑timesyncd, | ||
| + | ```bash | ||
| + | sudo timedatectl set-time " | ||
| + | ``` | ||
| + | y dejar que NTP haga los ajustes finos posteriores.[10][3] | ||
| + | - Comprobar otra vez: | ||
| + | ```bash | ||
| + | timedatectl status | ||
| + | ``` | ||
| + | Cuando el campo `System clock synchronized` pase a `yes` y el desajuste sea mínimo, la sincronización está funcionando correctamente.[7][3] | ||
| + | Si indicas si tu Debian 13 es servidor o escritorio y si tienes servidor NTP interno, se pueden proponer valores concretos para el `timesyncd.conf` o para `ntp`/ | ||
| + | * [1](https:// | ||
| + | * [2](https:// | ||
| + | * [3](https:// | ||
| + | * [4](https:// | ||
| + | * [5](https:// | ||
| + | * [6](https:// | ||
| + | * [7](https:// | ||
| + | * [8](https:// | ||
| + | * [9](https:// | ||
| + | * [10](https:// | ||
| + | \\ | ||