为什么我的柜台不工作?

时间:2014-06-18 14:04:56

标签: php bash shell

我有一个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

我试图在循环之前实例化计数器,但它以相同的结果结束。任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

您可能使用sh而非bash执行脚本。确保使用./script.sh直接执行它(以便使用shebang二进制文件)或使用bash bash script.sh

显式调用它