#!/bin/bash
# =================================================================
# 定期実行タスクの終了監視スクリプト
# =================================================================
# 監視対象のサービス一覧(.service を指定)
SERVICES=("task1.service" "task2.service" "task3.service")
echo "バックグラウンドタスクの終了確認を開始します..."
while true; do
any_running=false
for srv in "${SERVICES[@]}"; do
# サービスがまだ実行中(active)か確認
if systemctl is-active --quiet "$srv"; then
echo "待機中: $srv はまだ実行中です..."
any_running=true
fi
done
# すべてのサービスが停止(inactive)した場合はループを抜ける
if [ "$any_running" = false ]; then
echo "【安全】すべての定期実行タスクが正常に終了しました。OSのアップグレードが可能です。"
break
fi
# 2秒間隔で再確認
sleep 2
done
Last modification:October 8, 2026
© Allow specification reprint