You didn't tell us what your Python script did - or was supposed to do. We try to answer RPi-related questions here, but all of our mind-readers are currently on strike for better wages. So you're left to depend on people like me who need some information to provide answers.
All that said, I'm going to take a guess. I'll answer your question in this way - by a working example that is as similar to yours as I know how to make it:
Create a Python script in user pi's home directory;
$ nano hello.py
Enter a single line in the editor:
print("Hello from Python Script Launched run under cron")
Save & close the editor - check to ensure the file /home/pi/hello.py
exists
Open your crontab
for editing:
$ crontab -e
Make the following entry at the bottom of your crontab
:
* * * * * /usr/bin/python3 /home/pi/hello.py >> hellopy.txt 2>&1
Save & exit the crontab
editor - it should confirm that a new crontab
has been installed
You can see the once-per-minute output as it goes to the output file using tail
:
$ $ tail -f -n 10 hellopy.txt
Hello from Python Script Launched run under cron
Hello from Python Script Launched run under cron
etc, etc, etc
control + c to end the listing (or just use cat
instead of tail
if you prefer)
EDIT/ADDENDUM:
To view your user environment:
$ printenv
To view your "cron user's environment", add the following line to your crontab:
@reboot sleep 10; /usr/bin/printenv > /home/pi/cronenv.txt 2>&1
Review the differences between these two environments in light of your Python program.
/usr/bin/python3 /home/pi/main.py
from your CLI (the terminal)?