我有一个bash脚本,每15秒运行一次PHP脚本,每5分钟运行一个第二个PHP脚本。但是,我这样做的反击是行不通的。我无法找到错误的位置。
#!/bin/bash
while (true)
do
sleep 1
if (( count % 15 == 0 )) ;then
php test.php
fi
if (( count % 300 == 0 )); then
php test2.php
count=0
fi
(( count = count +1 ))
done
当我运行此脚本时,它在控制台中给出了这个错误:
script.sh: 8: script.sh: count: not found
script.sh: 11: script.sh: count: not found
script.sh: 16: script.sh: count: not found
script.sh: 8: script.sh: count: not found
script.sh: 11: script.sh: count: not found
script.sh: 16: script.sh: count: not found
我试图在循环之前实例化计数器,但它以相同的结果结束。任何帮助将不胜感激!
答案 0 :(得分:0)
您可能使用sh
而非bash
执行脚本。确保使用./script.sh
直接执行它(以便使用shebang二进制文件)或使用bash bash script.sh