2

is there a possibility to see output (f.e. std cout << ...) from my program which was started from rc.local script when i am logged into my Rpi via SSH?

3
  • 2
    What's wrong with redirecting the output to a file? Commented Jul 9, 2019 at 12:21
  • It is possible. I believe this could help you, but you will need the PID Process IDentification. Processus redirection Commented Jul 9, 2019 at 13:12
  • This question is ambiguous - if you want to log output use goldilocks answer, if you want to display output to the user do not use rc.local
    – Milliways
    Commented Jul 9, 2019 at 22:22

1 Answer 1

2

is there a possibility to see output (f.e. std cout << ...) from my program which was started from rc.local script when i am logged into my Rpi via SSH?

A process started by init (which includes stuff in rc.local) may not fare well if it outputs anything to stdout, which is why it is common practice to start them this way if you don't care about the output (eg., because it is trivial):

myprog > /dev/null

/dev/null is essentially putting the hose over the side of the boat.

If you do want the output:

myprog 2>&1 >> /var/log/myprog.log

You can collect it in a file. If you want to watch it grow live via SSH, use tail -f /var/log/myprog.log. The 2>&1 bit redirects stderr to stdout so they are interleaved line wise. If you don't want stderr, remove that.

1
  • Answere is good, just want to add if you want to actually SEE it, f.e. grab output from it from the console with another program (for whatever reason), you could write a simple starter thread in, have it start the process you want to monitor, and place the starter thread inside rc.local...
    – clockw0rk
    Commented Jul 10, 2019 at 12:19

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.