Please have a look at the following simple shell script startCleanup.sh
:
#!/bin/sh
screen -d -m -S cleaner /usr/bin/python3 /opt/cleanup.py
My crontab looks like this:
* * * * * /opt/startCleanup.sh > /opt/cleanup.log 2>&1
When I run this script in the shell as a nomrally logged in user I do not have any problems. However, if I run this as a regular cronjob, no screen is started. Or better said: The screen is started (I think) but when the script finishes and along with the script the screen is also terminated.
Does anybody have an idea how to solve this problem?
thanks :)
UPDATE: Okay, I now defintely know that the screen is properly executed (I checked that by adding a sleep at the end of the bash script).
So here is what happens: The screen is created. BUT when the bash script finishes the screen is also terminated. So, the screen still depends on the script.
How can I avoid that the screen is terminated when the script finishes?