轻量级文档与服务说明,面向小规模基础设施、静态网站部署与日常运维维护。
本站汇集关于 DNS 配置、HTTPS 部署、服务可用性检查、日志轮转、备份策略及常规 Linux 服务管理的实用笔记。内容作为简洁参考,用于以最小复杂度构建并运行可靠的 Web 服务。
轻量级文档与服务说明,面向小规模基础设施、静态网站部署与日常运维维护。
本站汇集关于 DNS 配置、HTTPS 部署、服务可用性检查、日志轮转、备份策略及常规 Linux 服务管理的实用笔记。内容作为简洁参考,用于以最小复杂度构建并运行可靠的 Web 服务。
使用 systemctl 管理 Linux 服务 Systemd 是大多数现代 Linux 发行版的默认初始化系统。systemctl 命令是管理服务的主要工具。本文介绍最常用的操作。 1. 查看服务状态 查看某个服务是否正在运行: systemctl status nginx 输出中包含活动状态、主进程 PID、内存占用和最近的日志条目。绿色的 active running 表示服务运行正常。 列出所有正在运行的服务: systemctl list-units --type=service --state=running 2. 启动和停止服务 立即启动服务: systemctl start nginx 停止正在运行的服务: systemctl stop nginx 重启服务: systemctl restart nginx 在不完全重启的情况下重新加载配置: systemctl reload nginx 3. 启用和禁用服务 启用服务使其在开机时自动启动: systemctl enable nginx 禁用服务使其不在开机时启动: systemctl disable nginx 一条命令同时启用并启动: systemctl enable --now nginx 4. 使用 journalctl 查看日志 Systemd 通过 journald 收集日志。查看特定服务的日志: ...
使用 systemd Timers 执行定时任务 在 Linux 系统上,定时任务通常与 cron 关联。cron 简单易用、广泛可用,至今仍有价值。但在使用 systemd 的现代 Linux 发行版上,还有另一个强大的选项:systemd timers。 systemd timer 可以在指定时间、开机后或固定间隔触发服务。与传统 cron 相比,systemd timers 与系统服务管理器集成更紧密、日志更清晰、调度选项更灵活。 本文介绍 systemd timers 的原理与配置方法。 什么是 systemd Timer? systemd timer 是一种单元文件,用于控制另一个 systemd 单元的激活时机。在大多数情况下,timer 激活的是一个 .service 单元。 一个典型的定时任务需要两个文件: /etc/systemd/system/example-task.service /etc/systemd/system/example-task.timer .service 文件定义要执行什么。.timer 文件定义何时执行。这种分离使得 systemd timers 结构清晰、易于管理。 简单示例:每日备份 假设我们要每天执行一次备份脚本。 首先创建脚本: sudo nano /usr/local/bin/daily-backup.sh 示例内容: #!/bin/bash echo "Backup started at Thu Jun 11 11:23:18 2026" >> /var/log/daily-backup.log tar -czf /tmp/etc-backup.tar.gz /etc echo "Backup finished at Thu Jun 11 11:23:18 2026" >> /var/log/daily-backup.log 设置可执行权限: ...
Static Site Deployment Checklist Static websites are simple to operate, but a few basic checks can make them more reliable and easier to maintain. This note summarizes a minimal deployment checklist for small documentation sites, project pages, and service information pages. 1. Confirm DNS Records Before deploying the site, confirm that the domain points to the correct server address. For most small websites, an A record is enough: A record for IPv4 AAAA record only if IPv6 is available CNAME record for aliases or subdomains Avoid adding unused records. Incorrect IPv6 records are a common cause of connection failures when the server does not actually support IPv6. ...