I want to execute a respawning bash script
which looks like the following
until python3 myapp.py; do
echo "$(date) -- every exeception" | tee -a /var/log/app.log
sleep 1;
done
This is basically respawning the script if it dies.
In the example of the link it only logs the $?
which might just be a number. But I wish to tee
the exceptions that occur when the script fails to the log/app.log
file.
I tried different stuff but nothing works. Any direction how I can get the exceptions logged in the above mentioned way.
trial
until python3 myapp.py; do
echo "$(date) > &2 >&1 | tee -a /var/log/app.log
sleep 1;
done
Output from log file
Fri May 18 18:09:03 UTC 2018 > 2>&1
Fri May 18 18:09:03 UTC 2018 > 2>&1
Fri May 18 18:09:04 UTC 2018 > 2>&1
Fri May 18 18:09:05 UTC 2018 > 2>&1
Fri May 18 18:09:06 UTC 2018 > 2>&1
Fri May 18 18:09:06 UTC 2018 > 2>&1
Fri May 18 18:09:07 UTC 2018 > 2>&1
Fri May 18 18:09:29 UTC 2018 >&2>&1
Fri May 18 18:09:30 UTC 2018 >&2>&1
Fri May 18 18:09:30 UTC 2018 >&2>&1
Fri May 18 18:09:31 UTC 2018 >&2>&1
Fri May 18 18:09:32 UTC 2018 >&2>&1
Fri May 18 18:09:33 UTC 2018 >&2>&1