On my Synology DS215j I have a scheduled task, that is executed every 5 minutes and checks, if a specific python script is running:
Works principially fine, but the execution of the task never ends (except the python script crashes). So, I tried to start it in background
Any ideas?
Bash:
#!/bin/bash
# Import environment variables ...
. /etc/profile
PYSCRIPT="telegram-bot.py"
if ! ps ax | grep -q "$PYSCRIPT"; then
echo "$PYSCRIPT is running"
else
echo "$PYSCRIPT not running, attempting to start..."
cd /volume1/homes/Python
exec python3 "$PYSCRIPT"
echo "$PYSCRIPT started!"
fi
Works principially fine, but the execution of the task never ends (except the python script crashes). So, I tried to start it in background
exec python3 "$PYSCRIPT" &
. But with this change, there is a huge disadvantage included, this line if ! ps ax | grep -q "$PYSCRIPT"; then
now always returns FALSE, so that the python-script is started again and again...Any ideas?