1

I have an embedded ARM device running Linux which launches an application on boot. This application has a bunch of "printf(...)" statements in it that I need to view. The normal way I have been approaching this is to kill the running app through SSH (from a host PC) on the embedded device after it boots, and then re-launch it via the SSH terminal so that I can see the print statements in the console on the host PC. The problem with this is that the app does not behave well after killing and re-launching it.

What I have attempted to do is edit the startup script to say "(nohup ./myAppName 2>&1 | logger) &" and view /var/log/syslog with tail -f.. however, nothing is getting logged.

I have verified that "(nohup echo "test123" 2>&1 | logger) &" does indeed log properly to the syslog.

Where might things be going wrong? Is it possible that the app is not printing to stdout/stderr? When I do relaunch the app, it does properly print to the console, but like I said, other things beyond the scope of this are broken when I do so.

  • When you "relaunch the app", would it also properly print to a file? – rudimeier Sep 27 '16 at 20:30
  • I have no tried relaunching and printing to file, but it would print to console just fine.. I am working on implementing your strace answer below and will post results soon – Hubert S. Cumberdale Sep 27 '16 at 20:41
  • If you already use nohup - why don't you just use the nohup.out file it generates, like described in the man page? – Jaleks Sep 27 '16 at 21:16
  • Jaleks I've tried this but nohup.out is blank... the program may not be as verbose if stdout is not a tty? – Hubert S. Cumberdale Sep 27 '16 at 22:08
1

Some program are less verbose when stdout is not a tty. You can emulate a tty using screen:

screen -L -d -m ./myAppName

which logs the output to something like ./screenlog.0. You need write permission in the current directory!

Otherwise it's also possible that the program simply fails silently only within your boot environment.

I would debug that using strace and avoiding logger:

strace -f -o /tmp/myApp.strace nohup ./myAppName >/tmp/myApp.log 2>&1
| improve this answer | |
  • myApp.log shows "nohup: ignoring input" and the .strace file is huge, lots of messages that I have to sort through. I think you are on to something when you say "less verbose when stdout is not a tty" how can I change that? Thanks again – Hubert S. Cumberdale Sep 27 '16 at 20:46
  • I've edited the answer regarding tty emulation. And yes, the strace log might be difficult to read for non-programmers. Maybe you see at the and why the program exists. – rudimeier Sep 27 '16 at 21:11
  • I don't have the screen command available D:, any other way? – Hubert S. Cumberdale Sep 27 '16 at 21:28
  • Can't you install screen? Otherwise you could post your strace output on pastebin.com if it does not contain private secrets. – rudimeier Sep 27 '16 at 21:43
  • I'm not sure if I can install screen on this ARM device, nor post the strace because it does have some sensitive information in it :< I think I am close, thank you for your tips – Hubert S. Cumberdale Sep 27 '16 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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