这是我到目前为止所拥有的:
until python MyApp.py; do
echo "App crashed... restarting..." >&2
sleep 1
done
这将在程序崩溃时重新运行程序,但在程序自行完成时不会重新运行。
答案1
也许这对你有用?
while True;
do
python MyApp.py || echo "App crashed... restarting..." >&2
echo "Press Ctrl-C to quit." && sleep 1
done