I have a site that uses a solr search engine, but I've only been able to use it while I'm ssh'ed into the server (Amazon EC2) and run the java -jar start.jar. As soon as I log out of the ssh session, it stops running and nothing is searchable anymore. How can I keep this running even when I'm not accessing the server?
If this needs any more clarification, just comment.
I use
nohup java -jar start.jar &
to achieve what you want.
Either convince it to run in daemon mode, or start it with something like setsid to disassociate it from your login session ID, so that it won't be terminated when your login session is.
Related
I am running a game server as a service using systemctl to start and stop a script that runs the whole thing. I tried to modify the script to let me use a screen so I could attach to the process that the server is being run on, and issue commands. But so far I've not had much luck. Is it possible to attach to services that are running on a server?
This question belongs on the Unix/Linux StackExchange.
See e.g:
https://unix.stackexchange.com/questions/453998/systemd-connect-to-stdin-stdout-after-service-has-started
If you want to solve it via programming, you could consider writing a small web application as the interface instead of the console.
Not in systemd, but you can start the service using
screen -D -m yourservice
which will create a detached screen session that will wait for the process to exit (so systemd does not see the service terminating immediately if you use this in an ExecStart line). You can then attach to that session normally.
I'm using Amazon EC2 to host my Node.js server. I connect through ssh from my desktop, and once I run my server via ssh, I can turn my console off and everything will still work, obviously, since the process is running on my remote EC2 hosting server. But once I ssh again, I know the Node process is still running, but there seems to be no way to view the process logs, and this server is still in early beta versions that the console logs are important. Any help?
You could redirect stdout/stderr to a file, which would allow you to use ordinary tools like cat and tail to view the logs.
If you don't want to write the log output to file(s), you could start the process in screen or tmux or similar and attach to the session later from ssh.
I am using derby on a remote Ubuntu 12.04 server. The standard derby commands are all working correctly and I am able to open my databases and access them via ij. I need to be able to start and stop the server from the terminal while logging in and out between commands. The problem is that I can not find a way to run the server as a background process. The closest I have come is: nohup java -jar $DERBY_HOME/lib/derbyrun.jar server start & > ~/dblog.txt which works except that it requires I hit [enter] before returning to the command line. I am aware of the daemon package but I am uncertain of whether it will allow me to then stop the server. What would be helpful is a explanation of how tomcat manages it since that is my app server.
Derby is just a Java application. Any technique you wish to use to run Java applications in the background (/etc/init.d, job control in your shell, etc.) will work fine for Derby.
You can use commands like "kill" or "killall" to kill your background process. Use "jobs" command to see list of running process you've sent to background. Also you can put them back in foreground by doing - "fg %n" (where n is the job number) and kill it using CTRL-C.
I'm using a ssh session on a Linux server to start an Embedded Jetty Server to run a web application that exposes web services. When I use the java -jar start.jar to bring up the Jetty web server instance I don't have access to the command line in that session and must open up a new ssh session in order to run a command line application that invokes the web services running on the jetty instance. Is there any way to run jetty in the background and in the same ssh session have access to the command line?
look at nohup, and as I recommended on the mailing list when you asked this same question, get to know the 'screen' utility, it is a wonderful tool to have in your toolbox.
I have a need to restart a CentOS service remotely via ssh during an automated, unattended process (executing a build on some software from a build server), but am unsure how to best implement security. Help is needed! ;-)
Environment:
Running an ssh login on a remote box, I want to execute on my server something like:
/sbin/service jetty restart.
The ssh call is being made during a maven build process (probably doesn't affect anything, really).
I want the ssh session to login with a user that has practically zero permissions on the server except to execute the above.
I can set up shared key access for the ssh session.
Thanks!
Good idea to use an ssh key. You can then use a 'forced command' for that particular key, so it won't be able to run any other commands. See http://www.eng.cam.ac.uk/help/jpmg/ssh/authorized_keys_howto.html