I altered the autostart.cron above so that I am trying to set the environment variable, and I also added a test script to write a log file to see if this file runs:
Code:
#!/bin/bash
export AUTOSTARTVAR="ZZZZZZZZZZ"
# The current working directory is necessary to find config.json
cd /home/sammy/dev/project_folder
# The next command is sent to background, allowing this bash script to exit
# /usr/bin/python3.8 /home/sammy/dev/project_folder/main.py start schedule &> /dev/null &
/usr/bin/python3.8 /home/sammy/dev/project_folder/test.py
test.py only contains the python.org example script for logging:
Code:
import logging
logging.basicConfig(filename='example.log',level=logging.DEBUG)
logging.debug('This message should go to the log file')
1. test.py runs, because I see the example.log appear. So I was wondering if my path to python wasn't right or folder permissions weren't. This tells me that path and permissions for main.py from the previous iteration were set correctly,
2. when I check env, I do NOT see the variable AUTOSTARTVAR="ZZZZZZZZZZ", so something is wrong with how I'm trying to set this in the bash script.
Of course, running 'export AUTOSTARTVAR="ZZZZZZZZZZ"' in the cli works as written.
Is it even possible to set my env variable in that same script?
Bookmarks