Files
2025-10-07 15:58:15 +08:00

70 lines
2.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 查看 timer 状态
systemctl list-timers | grep yt_update
# 查看 timer 的详细计划
systemctl status yt_update.timer
# 查看是否成功调用了对应的 service
journalctl -u yt_update.service
# 查看所有激活的定时器
systemctl list-timers
# 查看特定 timer 状态
systemctl status yt_update.timer
# 手动触发任务
systemctl start yt_update.service
# 查看任务日志systemd 层)
tail -f logs/systemd_update_yt.log
# 查看脚本输出日志
tail -f logs/update_yt.log
# 禁用任务
systemctl disable --now yt_update.timer
#--------------------------------------------------------------------------
# 文件部署 & 启动命令
# 将 4 个文件放到 /etc/systemd/system/
sudo cp yt_update* /etc/systemd/system/
sudo cp yt_update_week* /etc/systemd/system/
# 刷新 systemd 配置
sudo systemctl daemon-reload
# 启动并开机自启 timer
sudo systemctl enable --now yt_update.timer
sudo systemctl enable --now yt_update_week.timer
#--------------------------------------------------------------------------
#使 systemd 服务和定时器生效
#重新加载 systemd 配置,以使新的服务和定时器生效:
sudo systemctl daemon-reload
#启动并启用定时器:
sudo systemctl enable yt_update.timer
sudo systemctl start yt_update.timer
sudo systemctl enable yt_update_week.timer
sudo systemctl start yt_update_week.timer
# 检查定时任务状态
#查看 yt_update.timer 和 yt_update_week.timer 的状态,确保它们正常运行:
sudo systemctl status yt_update.timer
sudo systemctl status yt_update_week.timer
# 查看日志
update_yt.py 脚本的日志会保存在 /data/webapps/test_yt_data_update/logs/update_yt.log。
update_yt_week.py 脚本的日志会保存在
/data/webapps/test_yt_data_update/logs/update_yt_week.log
定时任务本身的日志(包括 yt_update.service 和 yt_update_week.service 启动信息)会记录在
/data/webapps/test_yt_data_update/logs/service_log.txt 中。
#你可以通过 journalctl 查看 systemd 服务的日志,也可以使用 cat 或其他命令来查看具体的脚本日志。
journalctl -u yt_update.service
journalctl -u yt_update_week.service