My cron jobs aren't running when trying to save the script output to a txt file
I am trying to have a python script run twice a day- once at 8:00 AM and again at 8:00 PM. My hope was to store the script output to a txt file on my computer named LOG_{date-time}.txt so I could look at "log" files in case something went wrong with the script. I set up the following cron job:
0 8,20 * * * python3 /script/working/directory/Script.py > /script/working/directory/logs/LOG_"$(date +"%d-%m-%Y")".txtAfter setting up the cron job I checked the script after 8:00 PM and noticed my script hadn't run yet (I have it set to update a spreadsheet file and leave a time stamp after each update).
I did a bit of troubleshooting on my own and found that if I ran the cron job without the output portion of it, it would work (I also found that the cron job logs are put out in UTC instead of my system time, but that is an issue for another time):
0 8,20 * * * python3 /script/working/directory/Script.pyIs there something I'm missing here? Shouldn't this store the scripts output to a file? I am a bit new to things here and have been trying to learn as I go with this but I'm just not sure where to go with this. It would be nice to be able to store the outpupt of my script for debugging purposes.
41 Answer
The main reason I can assume is either the log path doesn't exist or you don't have permission to write to the log path.
Try executing the command manually instead of the cron
python3 /script/working/directory/Script.py > /script/working/directory/logs/LOG_"$(date +"%d-%m-%Y")".txtYou will most likely see the error in your terminal.
2More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"