mirror of
https://github.com/kxgx/2.13-Ink-screen-clock.git
synced 2026-03-19 07:39:45 +08:00
Update clean.sh
This commit is contained in:
19
bin/clean.sh
19
bin/clean.sh
@@ -5,7 +5,14 @@ dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
||||
logdir=${dir%/*}
|
||||
screen_name="clean_screen"
|
||||
service_name="raspi_e-Paper.service"
|
||||
timeout_seconds=10 # 设置超时时间,例如3600秒(1小时)
|
||||
hold_time_seconds=10 # 设置维持时间,例如300秒(5分钟)
|
||||
|
||||
# 创建一个新的screen会话并运行Python脚本
|
||||
screen -dmS $screen_name /usr/bin/python3 -u $dir/$f_name > $logdir/log/clean-info.log 2>&1
|
||||
|
||||
# 等待维持时间
|
||||
echo "正在运行脚本,将在 ${hold_time_seconds} 秒后停止服务..."
|
||||
sleep $hold_time_seconds
|
||||
|
||||
# 停止raspi_e-Paper服务
|
||||
echo "正在停止$service_name服务..."
|
||||
@@ -17,12 +24,4 @@ for pid in $pids; do
|
||||
screen -S $pid -X quit
|
||||
done
|
||||
|
||||
# 创建一个新的screen会话并运行Python脚本,并设置超时时间
|
||||
timeout $timeout_seconds screen -dmS $screen_name /usr/bin/python3 -u $dir/$f_name > $logdir/log/clean-info.log 2>&1
|
||||
|
||||
# 检查是否超时并处理
|
||||
if [ $? -eq 124 ]; then
|
||||
echo "脚本运行超时,已终止"
|
||||
else
|
||||
echo "脚本运行完成"
|
||||
fi
|
||||
echo "脚本运行完成,服务已停止,screen会话已结束。"
|
||||
|
||||
Reference in New Issue
Block a user