Start a long-running program over SSH [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have a Virtual Machine that is running Ubuntu, and I can SSH into the Virtual Machine just fine. I can even start my python program over SSH using the following:
python foldername/app.py
I am on a Windows machine, using Git Bash to SSH. If I start my python program this, way I have to leave the Git Bash window open. How can I start the python program without having to leave the Git Bash open on my Windows machine? Any help is much appreciated!

you can use nohup:
nohup python foldername/app.py &
now you can close your connection and the program will keep running. You can find more information here and here.

Another option would be to use a virtual terminal, e.g:
screen
tmux
Both of them should be available via the ubuntu package manager.
Then (after logging in via ssh) issue the following commands:
screen
python myprog.py
CTRL+A D
or for tmux
tmux
python myprog.py
CTRL+B D
Then you can close your ssh connection and look at the output when you return later by typing screen attach or tmux attach
I'd personally recommend using tmux.

Two main approaches come to my mind, depending on what you are up to:
Make the program run as a daemon (a program that runs in the background, not connected to any terminal); if appropriate (and logistically feasible), configure the system-wide init system to start it.
Alternatively, just run the program under a terminal multiplexer program (like GNU screen) that implements a persistent virtual terminal that you can attach to/detach from as needed.

Related

Using linux commands in window terminal [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 months ago.
Improve this question
How can I use in the window terminal the linux commands?
For example: use the "ls" command to see the directories of the files inside the same window terminal, if someone knows about it, thanks in advance.
There are several ways to do that, depending on what you mean by your request:
You could use wsl (windows subsystem for linux) and have fun with the Linux shell inside Windows (It's running a linux distribution however, so I don't know if it's what you want).
I use personally git bash and I think that's what you want.
If by "using linux commands" you mean practising with the Linux environment, I strongly suggest to install a VM with Linux on it, or go as far as dual-booting it with Windows.
If you are experienced and you just want a way to have the same commands, then as I said, Git bash or also Cygwin are the way to go

GNU Screen can't find applications after log out [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I recently installed Ubuntu 12.04 sever on a new box. I ssh in, run a command (a do loop iterating over a perl script that forks off several processes each running an application [blastn] on the provided data), and detach using Ctrl-a d. When I run screen -r to resume, no problem, the loop is running happily. When I log out of my ssh session and log back on, I can still resume the screen session with screen -r, but now the loop has terminated with error messages stating that the application can't be found and/or the perl script can't be found. I've tried giving the full path to the perl script to my perl command (i.e. not using tilde), but no dice. Still gets lost after ssh logout / logon.
It seems this is particular to my Ubuntu server. Running the exact same loop / perl script forking off processes / applications through ssh into my Mac OS X box, it finishes happily even after logging out from ssh, so I wonder if this has something more to do with my Ubuntu server than GNU screen. Much searching online has yielded no answer, however, so I would appreciate any help that you may be able to offer.
I can only guess you may have an encrypted home directory which as decrypted version is mounted during your login time. As soon as the last login terminates, the decrypted version gets unmounted and your running processes have no access anymore to the files in your home directory.
You can check this by typing mount | grep ^/home/. If this shows ecryptfs as type of the mount, then this is the case.
If this shows nothing (or a file system type like ext3 or similar), then my guess is wrong.

SSH into Linux and Open GUI [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
So i know how to SSH into a box and create/modify directories etc. However I do want to know how I can open the exact GUI (For instance I want the Fedora environment that I have on my virtual machine) to open up. Meaning I need to be able to simply see my linux environment. Would anyone know how I can achieve this?
I am using a mac.
I'm presuming you want to see the gui you are running on the vm, which won't really help you here. You have a couple of options:
If you are running linux (or an X server like xceed) on the machine you are actually using, then you can enable X forwarding in ssh (-X on the command line) and then run your window manager from there.
Alternatively, you could look at installing a vnc server on your linux machine (I'd recommend tightvnc) and your host and connecting that way.
Either way this would be getting you a fresh desktop rather than what is visible on the console of the machine.
For the specific case of a virtual machine, as you mentioned, both vmware and virtualbox (I'm guessing you are using one of those) provide either vnc or rdesktop head support; you can then use either a vnc client or windows remote desktop client to connect to the actual console. In this instance this is probably what you want to do.
Set up a VNC server on your Linux machine, it can provide you with a desktop environment.

Unix Editors to run and test ssh commands [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am new to the world of Unix and would like to install some type of editor to run Unix ssh commands on my windows PC. If that is not possible then how can i go about practicing Unix commands? I would be making directories and storing data in them if that helps.
From what I am reading you want to practice working in a unix command line on your windows PC. Is this correct?
If so I might recommend you check out cygwin.
ref: http://www.cygwin.com/
cygwin can install on a windows machine and provide you with an emulated linux shell. you can do pretty much anything basic you can do in linux in cygwin.
I would recommend two things which will enable you to use ssh:
1) If you want to keep on using Windows but have a remote machine on which you could login via ssh I recommend PUTTY.
2) You can set up a virtual machine using e.g. VirtualBOX.
I think, running a Linux VM on virtualbox is a better choice. You have a complete system to play with.

PuTTY: Change default SSH login directory [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
In Windows, I use PuTTY to log in a Linux-based remote server via SSH.
Is is possible to change the default directory entry point I get to after I connect and login? (That would be a nice time saver.)
e.g. from server/home/ to server/home/subdir/subdir/
You can also change the directory within PuTTY itself:
Configuration → Connection → SSH
Fill in the "Remote command" field with the following:
cd subdir/subdir ; /bin/bash
Add cd subdir/subdir to ~/.bashrc or ~/.bash_profile, or
change the home directory of the user.
You could use screen to keep your current directory by always logging into the same screen session.
Add the screen command with parameters to your putty saved session under SSH>Remote Command.
See the screen documentation for which parameters to use.
screen -R -O -t mysession -S mysession -f
Depends on a lot of things. Mainly the server operating system. Most SSH servers run Linux or Unix of some flavor. When you connect via any method of remote text login (as SSH is one member of this category) such a system will automatically spawn a shell process to talk to you. That's probably "bash", and it runs various things on startup. Check out
man bash
to learn more. One of the many things you can do is cd to a subfolder.

Resources