I've created a python program that is launched at start-up. To launch it at start-up I've appended a row to the file /etc/rc.local as follow:

sudo python3 /home/pi/myProgram.py

Every some seconds, Myprogram.py prints a debug message. When I turn on my Raspberry, I cannot view myProgram.py to run. I'm sure that it works fine because when the program starts it sends me an e-mail but I cannot view the terminal window where myProgram.py prints the debug messages. Question: How can I view output of myProgram.py in a terminal window?

2 Answers 2


You can use

python3 /home/pi/myProgram.py 2>&1 | logger -t my-program

That way all output will end up in the system log in /var/log/syslog

  • One of the first things I do on a new Pi is disable all logging to the SD card (in an attempt to improve SD card lifetime) so it would not work for me. I'd certainly do this on a hard drive based machine.
    – joan
    Jul 9, 2015 at 10:36
  • You're right. That's probably a good idea on the PI with the default syslog setup. On a custom distribution I built I'm using busybox's syslogd which has the ability to log to a circular memory buffer. So it's not a problem in that case.
    – dividuum
    Jul 9, 2015 at 12:10

You do not need to use sudo for programs started in /etc/rc.local, they are run as root.

I suggest you redirect stdout to a file, e.g.

python3 /home/pi/myProgram.py >/tmp/mydebugfile

If possible replace /tmp (or whatever you choose) with a file system stored in RAM or on the nextwork to minimise SD card read/writes.

Then to view your debug messages use

tail /tmp/mydebugfile

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.