Zend certified PHP/Magento developer

Screen fails to properly load when called with crontab

What I’m doing

I’ve been migrating one setup to another, copying configuration and installing dependencies, I was about to be done until screen didn’t work as intended.

I have a script that I keep runing on a detached screen that I initialize on boot, the setup is practically identical to the one on the old machine, still no luck

What I have:

  • an Ubuntu 20.04 machine
  • a bar.screenrc with:
screen sh /path/to/file/foo.sh
  • a foo.sh with:
#!/usr/bin/env python3.8
cd /path/to/file/
gunicorn --bind 0.0.0.0:5002 wsgi:app --log-level debug --error-logfile gunicorn.log
  • a cronjob with:
@reboot /usr/bin/screen -c /path/to/file/bar.screenrc >> /path/to/file/cron.log 2>&1 -dmS API

The scenario

On reboot no new session appears, however, if I copy and paste the line (without the @reboot), it’ll work as intended.

I tried changing the .screenrc to /usr/bin/screen /usr/bin/sh /path/to/file/foo.sh and this change does initiate a detached screen, but its not running the gunicorn instance

This exact same scenario works on the old setup and has worked on other projects of my own in the past

Disclaimer

I know things can be done with services instead of screen, this is out of the current scope of the project and this question.