我相信我已经为我的 if else 语句正确设置了所有内容,但是它一直将内容输出到我的 shell 终端中,就好像我自己运行了命令一样。无论如何我可以逃避这个,所以我可以运行这些命令而不用结果中的文本填充我的终端?
#!/bin/bash
ps cax | grep python > /dev/null
if [ $? -eq 0 ]; then
echo "Process is running." &
echo $!
else
echo "Process is not running... Starting..."
python likebot.py &
echo $!
fi
这是运行我的 bash 脚本几分钟后的输出
[~]# sh check.sh
Process is not running... Starting...
12359
[~]# Your account has been rated. Sleeping on kranze for 1 minute(s). Liked 0 photo(s)...
Your account has been rated. Sleeping on kranze for 2 minute(s). Liked 0 photo(s)...