I'm currently using crontab on a Raspberry Pi 4 Model B to launch my python script at boot.
I've added this at the bottom of sudo crontab -e
:
@reboot sh /home/pi/start.sh > /home/pi/logs/cronlog 2>&1 &
My start.sh
script is like that :
#!/bin/sh
# start.sh
cd /home/pi/Desktop/Python_Scripts/Projet
sudo python3 main.py
If I run the shell script manually, everything works fine, but when it runs at boot, the serial communication doesn't work.
I already tried to add some delay in my python script to wait for the serial interface to be fully initialized but it still doesn't work.
Thanks in advance for any kind of help
EDIT : I must clarify that the script runs perfectly if I run
sh /home/pi/start.sh > /home/pi/logs/cronlog 2>&1 &
in the command line. However, the only thing that doesn't work if I run it at boot with crontab is the serial communication (looking up signals with an oscilloscope, it doesn't send data through the serial interface) but every other aspect of the program runs fine.