#!/bin/bash
# 循环检查后台进程
while true; do
# 检查 jobs -l 输出,不输出结果,错误重定向到/dev/null
jobs -l > /dev/null 2>&1
# 如果有后台进程在运行
if [ $? -eq 0 ]; then
echo "There are background jobs running. Sleeping for 1 hour."
sleep 1h
else
echo "No background jobs running. Proceeding with the execution."
break
fi
done
# 主代码
echo "Executing main code..."
# 在此处放置你的主代码