Syntax error: end of file unexpected (expecting "do")

Syntax error: end of file unexpected (expecting "do")

我有一个非常简单的文件,"retrieve4.sh"

完整代码如下:

while [ 1 ]
do
nohup php retrieve4.php 1 > /dev/null 2>&1 &
nohup php retrieve4.php 2 > /dev/null 2>&1 &
done

我一直收到错误消息

Syntax error: end of file unexpected (expecting "do")

我哪里错了?

如果应该是无限循环试试

while [ 1 = 1 ]
do
nohup php retrieve4.php 1 > /dev/null 2>&1 &
nohup php retrieve4.php 2 > /dev/null 2>&1 &
done

编辑

while [ 1 ] 
do 
echo 'test' 
done

这 运行 我的设置非常好。因此,我希望您的 运行 脚本方法是错误的

您也可以尝试这样的操作:

while true ; do php my_script.php ; done > /dev/null

根据上面的评论,您提到 "I'm editing it on Windows and the server is Linux",return 回车可能导致了问题。

尝试单线解决方案验证:

while true ; do php retrieve4.php ; done > /dev/null