更新 e-Paper_clean.servic

This commit is contained in:
星光-k
2025-01-20 23:19:27 +00:00
committed by GitHub
parent c3666059ce
commit 7a76aef402

View File

@@ -1,23 +1,14 @@
#!/bin/bash
[Unit]
Description=Run e-Paper clean on shutdown and reboot
DefaultDependencies=no
Before=shutdown.target
Before=reboot.target
f_name="clean.py"
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
logdir="${dir%/*}/log"
service_name="raspi_e-Paper.service"
[Service]
Type=oneshot
ExecStart=/bin/bash /root/2.13-Ink-screen-clock/bin/clean.sh
RemainAfterExit=yes
# 停止raspi_e-Paper服务
echo "$service_name..."
sudo systemctl stop "$service_name"
# 确保日志目录存在
mkdir -p "${logdir}"
# 获取并终止所有与脚本相关的进程
pids=$(pgrep -f "$dir/$f_name")
if [ -n "$pids" ]; then
kill -9 $pids
fi
echo ""
# 运行Python脚本并将输出重定向到日志文件
/usr/bin/python3 -u "$dir/$f_name" > "${logdir}/info-clean.log" 2>&1 &
[Install]
WantedBy=shutdown.target
WantedBy=reboot.target