Several weeks ago in Cronjob Redux I wrote that I had finally gotten Cron to automate the entire process of compiling the
h264 files into an
mp4 and uploading it to YouTube.
I hadn’t. And it took the better part of the last 2 weeks to figure out what the heck was going on.
Part of what I wrote before was correct. I wasn’t able to read the
client_secrets.json file and that was leading to an error.
I was not correct on the creation of the
The reason I got it to run automatically that night was because I had, in my testing, created the
create_mp4.sh and when cron ran my
run_script.sh it was able to use what was already there.
The next night when it ran, the
create_mp4.sh was already there, but the
h264 files that were referenced in it weren’t. This lead to no video being uploaded and me being confused.
The issue was that cron was unable to run the part of the script that generates the script to create the
I’m close to having a fix for that, but for now I did the most inelegant thing possible. I broke up the script in cron so it looks like this:
00 06 * * * /home/pi/Documents/python_projects/cleanup.sh
10 19 * * * /home/pi/Documents/python_projects/create_script_01.sh
11 19 * * * /home/pi/Documents/python_projects/create_script_02.sh >> $HOME/Documents/python_projects/create_mp4.sh 2>&1
12 19 * * * /home/pi/Documents/python_projects/create_script_03.sh
13 19 * * * /home/pi/Documents/python_projects/run_script.sh
At 6am every morning the
cleanup.sh runs and removes the
h264 files, the
mp4 file and the
At 7:10pm the ‘header’ for the
create_mp4.sh runs. At 7:11pm the ‘body’ for
create_mp4.sh runs. At 7:12pm the ‘footer’ for
Finally at 7:13pm the
run_script.sh compiles the
h264 files into an
mp4 and uploads it to YouTube.
Last night while I was at a School Board meeting the whole process ran on it’s own. I was super pumped when I checked my YouTube channel and saw that the May 1 hummingbird video was there and I didn’t have to do anything.