if ps aux | grep "${program_name}" | grep -v grep > /dev/null; then echo "$(date +%Y-%m-%d\ %H:%M:%S) - ${program_name} is running normally." >> "${log_file}" else echo "$(date +%Y-%m-%d\ %H:%M:%S) - ${program_name} is not running. Please check it." >> "${log_file}" fi我要每六十秒检查一次要怎么修改
时间: 2024-03-05 08:53:39 浏览: 313
PyPI 官网下载 | better_fasta_grep-1.0.0.tar.gz
您可以使用`sleep`命令来等待一定的时间后再进行下一次检查,例如:
```
while true; do
if ps aux | grep "${program_name}" | grep -v grep > /dev/null; then
echo "$(date +%Y-%m-%d\ %H:%M:%S) - ${program_name} is running normally." >> "${log_file}"
else
echo "$(date +%Y-%m-%d\ %H:%M:%S) - ${program_name} is not running. Please check it." >> "${log_file}"
fi
sleep 60
done
```
这个脚本将会每隔60秒执行一次`if`语句,并根据程序是否在运行中输出相应信息。注意,这个脚本将会一直执行下去,直到您手动终止它。
阅读全文