Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29250

Crontab Launches Python Script but SystemD Does Not?

$
0
0

I can log into my AWS EC2 server via ssh and type:

cd /opt/myWebApp
sudo python3 /opt/myWebApp/manage.py myCronJob

...and it runs.

I can also launch the same script via crontab:

0 */6 * * * sudo python3 /opt/myWebApp/manage.py myCronJob --settings=server.settings.production 

But when I try to run it in SystemD, with .service file:

ExecStart='/usr/bin/python3.7' /opt/myWebApp/manage.py myCronJob --settings=server.settings.production

...I get:

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

$PYTHONPATH and $VIRTUAL_ENV are empty. /opt/myWebApp/server_venv is empty as well. There's a python at /usr/bin/python3.7, but I'm referencing that in the SystemD .service file as noted above, and it's throwing that error.

What am I missing?


Viewing all articles
Browse latest Browse all 29250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>