I recently decided to migrate my programs from AWS to a local server (Raspberry Pi 3 B+ running Raspbian). I SSH into the now local server where I send the following command (and please correct me if I'm wrong).
nohup ./Eye.sh & nohup ./Hand.sh & nohup ./Foot.sh &
The program does nothing over the weekend (and it is current 2AM on Sunday here) and will not start performing its task until 9:30AM on Monday. I need to know that I will not, hopefully ever, have to SSH back into the server to re-execute the commands, as it is crucial that the programs are running at all times.
Do I have anything to worry about? Will the program run as long as there is power to the system?
Yes. As long as the server is running, you can close out of your SSH connection and your program will continue to run with the nohup command. If your server reboots, for whatever reason, you should consider using respawn.
Related
I'm using Django on Ubuntu 18.04.
I've got everything set up. And I type python manage.py run_huey in the server (through an SSH connection) to start huey, and it works.
However this is done through the command line through SSH and it will shut off when I close the SSH connection.
How do I keep run_huey running so that it will stay active at all times? Furthermore, after a system reboot, how do I get run_huey to automatically start?
You may explore supervisorctl utility for ubuntu, it keeps process running and can log into file and any other features. Google it.
I have a raspberry PI on which I run a node server. To start and control the terminal on which the server runs I use desktop remote to remote control the raspberry. Now this method is really slow so I was wondering, since I only need a command line anyway if I couldn't just connect to my raspberry pi using ssh for example.
My question now, would be if I do so, can I navigate to my node folder, run my node file and then close the ssh connection? Will my Node server keep running and if so how would I access the terminal with the node session after closing the connection?
The easiest way to do this is something like:
nohup node myapp.js &
This will make the app run in the background, and nohup prevents it from stopping when the connection closes.
This is a cheap and quick way to do this. A more appropriate way might be one of the following:
Using something like docker to manage running applications.
Using something like supervisord to do the same thing.
Writing scripts for initd and turn it into a real 'service'.
Changing the node application to fork & deamonize itself.
actually I have 2 jars and 1 ini file. In terminal I can run this java application like that :
"/usr/java/jre1.8.0_121/bin/java" -cp "./eSign.jar:sqlite-jdbc-3.7.2.jar" ./esign.tubitak.applet.SignApplet /home/ugurcan/Desktop/Linux_sign_test/test.ini
And my gui based program works like this. Now; I need to make this program run without any terminal commands like an exe as a session(which runs in backgraound always). Additionally , I need to add a websocket for the server to program makes a connection between the server and the computer which runs the program.
Thank you for your thoughts !!!
To run a command in background you can use:
nohup COMMAND &. nohup - makes your program immune to terminal hangup, and & runs it in background.
Can't figure out what do you mean 'to add a websocket for the server to program makes a connection between the server and the computer which runs the program'. Websocket support should be added in your application. But without any further detail we can't help you.
I am running a Node.js server on a DigitalOcean droplet (with Ubuntu). I have worked out how to make it run when I'm not connected to it via Putty. However, just one issue: how do I stop it now?
I can see that control+C works when in the session, but what if I exit the session and come back? How will I stop the server then?
Also, will running it multiple times run multiple servers at once?
Thanks!
You really should be using a tool like supervisord (http://supervisord.org/) for your long-running processes.
But if you want to stop an already running process that you started with nohup then look up the process ID first (with ps aux and look/grep for your process) and then run kill <<pid>>.
I have ssh-ed to a remote machine. I have enabled X11 forwarding (ssh -X) and I have started a GUI program.
The program takes 5 minutes to set up to do some processing but the actual processing takes 1-2 hours. I don't want to stream data while the program is working. I don't even want to see the program again as it produces files as output when it finishes and I can just scp them.
So how can I quit the ssh session but leave the program running on the machine? CRTL+C in the terminal?
EDIT: For the answer please see my comment just below.
Long story short - you can't do this without making some modifications to the way you run things. A GUI application requires for an X server target to be accepting it's GUI updates - if you're using your local X server to do this, then it'll require (1) the connection to be open (2) that you actually handle the updates.
A way around this is to use something like Xvfb - which is a headless way of hosting a virtual X-server. Above and beyond the examples provided on the wikipedia page, folks who seem to make frequent use of this mechanism are Selenium users.
Awesome, I've been looking for an acceptable answer to my problem for hours, and finally one pops up. ssh -X -f login#machine yourprogram worked perfectly for me. Though I used ssh -Y -f login#machine yourprogram. This has been driving me nuts.
Like some people said, SSH -X is using your local X server, so it needs the connection. I had the same problem, wanted to quit ssh but leaving GUI applications running. To do this I installed X server and VNC server on the remote host. With a VNC client on your local computer, you can easily connect to the VNC server and disconnect leaving GUI applications running.
By the way, you will have better performances with VNC or X2Go. In my case, Firefox was very slow and some sites didn't load at all with SSH -X, even with -Y or -C optimizations.
Running ssh -X -f login#machine yourprogram should do the trick.
Starting your program with nohup program & will make it safe to just close your terminal - program will still be running.
You won't be able to see the UI after you end ssh session, but since you don't need it anyway - it's going to do the job.