I am working a project to read an RFID tag, and make the buzzer sound. It works correctly in foreground. I call the python script via /etc/rc.local and it is triggered when I execute /etc/rc.local via ssh session. However, when I reboot my raspberry pi, the RFID reader does not respond. I can see the process via ps -aef|grep python. I am following this tutorial.

At /etc/rc.local I added this command just right before exit 0:

/usr/bin/python /home/pi/myscript.py &

To successful test it I log in as user pi from ssh and execute:

pi@raspberrypi:~ $ /etc/rc.local

Please help here.


  • What actual command did you add to /etc/rc.local ?
    – CoderMike
    Nov 1, 2018 at 17:22
  • i am using /usr/bin/python /home/pi/myscript.py &
    – Himanshu
    Nov 1, 2018 at 17:28
  • Redirect any output to a log : /usr/bin/python /home/pi/myscript.py >> /home/pi/templog.txt 2>&1 &
    – CoderMike
    Nov 1, 2018 at 17:31
  • 1
    Read this
    – Seamus
    Nov 1, 2018 at 18:11
  • 1
    Yes..you are right..I think issue was in GPIO.cleanup() and i called it in first line of program and after each GPIO call and it is working now...Thanks a lot for your help..
    – Himanshu
    Nov 3, 2018 at 6:14

2 Answers 2


How to capture output from a python script failing at startup:

Redirect any output to a log:

/usr/bin/python /home/pi/myscript.py >> /home/pi/log.txt 2>&1 &

2>&1 redirects standard output (stdout) and standard error (stderr)

Force Pythons buffered output to be flushed:

Add 'import sys' at the start of your code, then 'sys.stdout.flush()' after every print statement.

import sys

Remove error handling:

Remove any try: finally: blocks that may be handling/hiding any errors that may be occurring.


I assume you are using Raspbian Stretch. This comes with systemd which emulates /etc/rc.local. Because of this emulation it is known that it has problems. Look at Compatibility with SysV. As suggested there you should use systemd direct to start services. But first remove the line from /etc/rc.local. Then you have to create a unit. Do it with:

rpi ~$ sudo systemctl --force edit myscript.service

In the empty editor insert these statements, save it and quit the editor:

Description=My Script

ExecStart=/usr/bin/python /home/pi/myscript.py


Then enable and start your new service with:

rpi ~$ sudo systemctl --now enable myscript.service

Check with:

rpi ~$ systemctl status myscript.service
rpi ~$ journalctl --unit=myscript.service

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.