I have an on_reboot.sh
file that contains the following:
#!/bin/bash
source /home/pi/.profile
workon cv
cd /home/pi/reboot
python pi_test.py
After that I made the file executable using
$ chmod +x on_reboot.sh
and then in my crontab I put the following to run it on boot:
@reboot /home/pi/reboot/on_reboot.sh
However, it is not working when the Pi boots up. When I run the sh file on the command line it is working fine. I tried modifying the crontab like this:
@reboot sudo su – pi bash -c ‘/home/pi/reboot/on_reboot.sh’
to run the startup script as user pi but is not working either. How can I fix this?