I have a script that is ran at startup that launches a java console application. This works great. However, I want to be able to log into the Beaglebone via ssh and see the output of the java app to make sure everything is running ok. Since the java app was started by a service, I can’t see what was actually printed to the console. So I did some research and found that I should be using screen or nohup to pipe the output to another terminal or a file. I tried both, but neither work. The service is started, but the application is killed as soon as it is started.
So, I began debugging by executing my script in a screen, detaching and loging off ssh. However, as soon as I logoff, the java application dies. I know it’s at logoff becuase I have a user LED turns on when the app starts and off when it exits. This was discovered 10 months ago by someone else here: https://groups.google.com/forum/#!msg/beagleboard/S_R8NaCaiL8/mozkc_unbsEJ.
This still does not seem to be resolved. Does anyone know how I can do this? I just want to be able to log in and see the output. I know I could rewrite the java app to write to a file rather than print to the console, but I would rather save that for a last resort kind of thing.
Yes, it appears this issue was never resolved on Angstrom – I still have the same problem using the latest image and kernel.
Two options are:
Use systemctl to run your application. Here’s a post on StackOverflow that gives an example, and you can Google systemctl for more info. http://stackoverflow.com/questions/11152657/angstrom-start-up-processes-beaglebone. I use this approach to run Python apps and it’s very reliable: hopefully it will work fine for a Java app too. Logging to a file works fine, but I don’t know of a way to display the console output other than redirecting it into a file.
Switch to Ubuntu. Screen and nohup work normally there.
Yep, I’m already using systemctl, so looks like I will have to output to a log file after all. Bummer.
There is a way to make screen work in the way you describe. This is an issue with the dropbear configuration. By default, the SSH daemon (dropbear) on the BeagleBones are configured to kill all user procesess as soon as the user logs off. This makes it difficult to leave processes running in the background for debugging. To change this, edit the dropbear@.service file in /lib/systemd and add the “KillMode=process” line:
root@beaglebone:/lib/systemd/system# cat dropbear@.service
Description=SSH Per-Connection Server
ExecStart=-/usr/sbin/dropbear -i -r /etc/dropbear/dropbear_rsa_host_key -p 22
ExecReload=/bin/kill -HUP $MAINPID
You can either reboot the system for these changes to take effect, or reload the systemctl config and restart the dropbear service.
Thanks! That works perfectly.
That works when I call screen directly, but when it is called from a service (systemctl), it does not seem to work. Is there something else I need to enable?