我正在使用termux,它没有初始化系统,我找到了一个脚本来启动应用程序时启动crond
if ! pgrep -f "crond" >/dev/null; then
echo "[Starting crond...]" && crond && echo "[OK]"
else
echo "[crond is running]"
fi
这段代码非常适合 bash shell。
我目前正在使用鱼壳,并尝试在相当于bash_profile AKA 的鱼中使用相同的代码config.fish
但是,我收到了错误消息
Missing end to balance this if statement
if ! pgrep -f "crond" >/dev/null; then
^
from sourcing file ~/.config/fish/config.fish
called during startup
请帮我翻译,我正在阅读鱼文档,但是我需要很长时间才能正确完成。
格伦-杰克曼的这个回答很有帮助 https://stackoverflow.com/a/29671880/5257034
我能够在config.fish
运行代码而没有问题
我的代码
if ! pgrep -f $crond >/dev/null
echo "[Starting crond...]"; and crond; and echo "[OK]"
else
echo "[crond is running]"
end
您应该从本教程开始。在那里,您将了解到if
块如下所示:
if pgrep -f "crond" >/dev/null
do_something
end