1

I have a cron job set up to run boot.sh on reboot, and log the input to debug.txt.

@reboot cd /home/<user>/code/seasons-pixel-clock/ && (sudo bash boot.sh) > debug.txt

The contents of boot.sh are as follows:

cd /home/<user>/code/seasons-pixel-clock
sudo git fetch
sudo git pull
sudo python3 src/main.py

Now from the above, I would expect git pull and git fetch to occur on boot. However, neither occurs. Main.py does execute, however. Moreover, no error is printed in debug.txt.

What is the correct way to git pull/fetch on boot?

5
  • Can you please share contents of debug.txt? Why do you use sudo with git?
    – Vadim
    Commented Sep 14, 2022 at 7:48
  • Didn't you forgot to put shebang in your shell script e.g. #! /bin/sh? I'm not sure if it is absolutely necessary in this case, but might be a good idea to add it.
    – Vadim
    Commented Sep 14, 2022 at 8:01
  • @Vadim the contents of the file are empty, as I said.... I added the shebang, but that didn't change anything unfortunately. Commented Sep 15, 2022 at 0:35
  • how do you know that main.py is executed? Also, how about sudo, is there a reason for you to use it with git? Can you add echo test or better echo $PWD line in the script to check if it will appear in the debug.txt file?
    – Vadim
    Commented Sep 15, 2022 at 6:48
  • I know main.py works because it interfaces with a LED display, and the LED display turns on. Yes, I should have mentioned that I have debug text printing... debug.txt just doesn't catch it for some reason. Running main.py in the console normally does display the text however. sudo is required for main.py. Since I also have a git user attached to root, I just used it there too. The same result occurs either way. Commented Sep 16, 2022 at 3:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.