So I have a python script that is using the raspberry pi serial RX,TX to communicate with a 4D System Display. It is working just as I want it to work, BUT, when I modify the /etc/rc.local to let this script run automatically at startup, and apply a reboot, the screen which uses the serial interface is not working. Knowing that all other tasks are working correctly, just the serial interface didn't work. So the problem might be that my script is running before serial interface is booting completely. so is there any workaround for such situation?


3 Answers 3


I found the solution just in case someone else faced the same issue, the solution is to use crontab instead of rc.local file:

sudo crontab -e

Scroll to the buttom and add this line:

@reboot python /home/pi/MyScript.py &

I had a similar issue. My script calls the serial ports ttyACM* and I use .config/lxsession/LXDE-pi/autostart to launch it at startup. As I was having problems with this approach, I checked the .cache/lxsesion/LXDE-pi/rpi.log and I found out my script was not able to open the serial port only at startup, right after boot. It was not a matter of permissions or timing. After few negative attempts playing with crontab, bash and lxsession, I removed sudo apt-get purge modemmanager as suggested in the Arduino forum and now my script works as expected.


In the Python file, import time and add a time.sleep(seconds) in the beginning of the code. Also in the /etc/rc.local file, add a "&" sign together with the line starting the python script.

This will allow the pi to boot completely while still starting the python file automatically, this should work :)

  • I already tried that, but it didn't worked... but I got the solution which is using crontab instead of rc.local file, just like this: sudo crontab -e, and adding @reboot python /home/pi/MyScript.py & to the end of the file
    – Dani
    Aug 10, 2016 at 7:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.