gpt4 book ai didi

linux - shell 脚本错误 [ : 12: unexpected operator?

转载 作者:太空宇宙 更新时间:2023-11-04 09:04:04 28 4
gpt4 key购买 nike

#!/bin/bash
value=$(</var/www/sym_monitor/manthan.txt)


if [ "$value" == "true" ]; then

ps -ef|grep sym |grep -v grep |awk '{ print $2 }'|sudo xargs kill -9;


(cd /var/www/symmetric-ds-3.1.6/bin;sudo ./sym --port 8082 --server);

fi

当我手动运行这个脚本时,它运行良好,但是当我在 cron 中运行这个脚本时,它给出了以下错误。

[: 12: 意外的运算符

知道为什么吗?有什么建议吗?

最佳答案

您不是在 bash 中运行脚本,而是在不同的 shell 中。对于 POSIX 兼容的 shell,使用单个 = 而不是 ==

关于linux - shell 脚本错误 [ : 12: unexpected operator?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14934185/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com