I have created a bash file that executes a python script on an existing screen called 'cronscreen'. The bash file contains the following line:
screen -S cronscreen -X stuff "python test.py$(printf \\r)"
When I run the file from the command line, it works fine, and I see the output is printed when I attach my 'cronscreen'. However, I would like it to run in cron, so I have set up crontab as follows:
* * * * * myuser /home/myuser/myscript.sh > /home/ec2-user/agg.log
The cron is executed because I can see that the file agg.log is regenerated every minute, but when I attach 'cronscreen', I see no output printed there (and agg.log is empty). Why is that? Thanks.
Update:
I also tried changing the script to this(re-attaching the screen), but no change:
screen -r cronscreen
screen -S cronscreen -X stuff "python test.py$(printf \\r)"