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?
-
2What's wrong with redirecting the output to a file?– Dmitry GrigoryevCommented 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– Wireless LearningCommented 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– MilliwaysCommented Jul 9, 2019 at 22:22
1 Answer
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.
-
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... Commented Jul 10, 2019 at 12:19