Issue
If I run rsync inside screen
, then after a while I can login to the server and attach the detached screen
.
Now I want to run rsync from crontab
. I added this entry to crontab:
03 19 * * * root /usr/bin/screen -dmS rsyncSess uptime
After crontab executes the command, I run screen -ls
but nothing is listed.
After I run /usr/bin/screen -dmS rsyncSess watch -n 5 uptime
I can see that session when run screen -ls
.
How can I run a script in screen
from crontab
and then attach that screen session to see the output of rsync (even after rsync is finished)?
Until now I found this tread.
Solution
Make sure you:
- run
screen -ls
as the same user that is used by crontab to start your command - use a main command that doesn't end before you reattach, since that will end your session as well. If you run a short command and want the session to persist, use something like
bash -c 'short_command; exec bash'
(or, as pointed out in the link you mention, adddefzombie ZZ
to your.screenrc
).
Answered By - Sir Athos Answer Checked By - Timothy Miller (WPSolving Admin)