0

I have created the following script:

#!/bin/bash 
cd /home/pi/workspace/my-app
/usr/bin/git pull
python3 main.py &

If I run the script from the console, git pull is executed as expected and then the script main.py also runs as expected.

I added the script to cron in order to run on reboot:

@reboot /home/pi/custom-script.sh

When the RPi is rebooted, however, the python script is executed as expected, but git pull doesn't update anything.

Does anyone know how what could prevent git pull from executing?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

0

It turned out that the problem was that the script was executed before the networking was ready. After modifying cron definition such that the script is executed with the delay of 60 seconds, everything works as expected:

@reboot /bin/sleep 60 ; /home/pi/custom-script.sh