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 1 year ago.
Improve this question
How to keep the process running on remote server even if the ssh connection is closed?
You can use screen to detach a session. You connect to your ssh server, launch screen and then your computation...
At your next connection, screen -a to attach previous sessions
see : http://www.bangmoney.org/presentations/screen.html
Another idea would be to use tmux which works like screen but it is more flexible and easier to use (in my opinion). To keep a process running you could simply start a tmux session with the command tmux.
This will "open a new terminal" in which to run your programs, if you want you can give a name to the session to easily find it in case you have multiple sessions with the command ctrl+b $ instead of using the default name (e.g. 0).
After running the programs you need in the tmux session, you simply detach from the session with ctrl+b d and go back to the normal terminal from which you can call exit and close your ssh connection.
When you log in again, you simply run tmux attach -t <session_name> to go inside the session where you left your tasks running.
tmux offers a lot of other functionalities too, like screen splitting inside the session with ctrl+b % or ctrl+b " for vertical and horizontal splitting. (you can move between different screens with ctrl+b <arrow in the direction of the screen you want to go to>.
You can run your process/command inside a screen or tmux session,
Or you can do:
yourcmd &
disown
All these Answers are correct but if you are initiating SSH from a code and giving bash commands then they don't work. The best way is to use this command
nohup command > /dev/null 2>&1 &
Related
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 2 years ago.
Improve this question
I have program that I need to run and then see how much resources it uses in unix by using top command. But I don't know how to do it because if i run it from command line I cant use top command till program is finished and vice versa. How can I do it. I tried doing:
sleep 10s
top
./myProgram
But its not working
Open two terminals; run your program in one terminal and top in another.
If you're in a graphical environment, you can just start the terminal a second time.
If you're on the text-only console, you can switch between terminals using Ctrl-Alt-F1..F6 (possibly more) or Alt-Left/Right.
If you connect via SSH, just open multiple terminal sessions in your SSH client.
(Also, I'd hint to use htop instead of top, but you may need to install it first.)
In case your program is too short-lived to show up on top/htop, you might need to run it using Valgrind.
Open two terminals one for running top, and run your program in the other.
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 5 years ago.
Improve this question
Ok so I know it's a weird case but hang in here with me.
So the thing is I've got an very old laptop running ubuntu 14.04 server without any desktop aka shell only. BUT the laptop also has a touch screen so we want to be able to use the "mouse"/touchscreen/touchpad to select text inside the terminal and/or click/copy/paste/cut/etc. It's part of art project with some students and also one of the tasks is to run as less as possible. So running a desktop in the background is not really an option. My question is:
Is there a way to start the Ubuntu terminal as UI application in fullscreen without the actual desktop in the background but giving the functionality of an mouse cursor.
(If someone knows a even better solution for adding a mouse without starting the desktop its appreciated)
Try this: create a ~/.xinitrc with content : exec gnome-terminal, then run startx
Or another solution is to stay in tty and install gpm for mouse control
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 5 years ago.
Improve this question
I'm currently using an extra monitor so I'm running two tmux sessions in two separate terminals (one for each screen). The problem is every time I want to move between screens I have to manually move my cursor and click the other screen before my cursor will move over, this is super annoying. I'm on MacOS 10.12, using v2.7 of Terminal and v2.2 of tmux.
I've currently tried:
cmd + shift + arrow keys, but that only works when the tabs are actually stuck together on the same screen
Using tmux switch -t [] or tmux attach -t [] doesn't manually move the cursor over, it just changes the current screens session, syncing the one session onto both screens.
Just using one session, but there's this annoying quirk where the external monitors dimensions fit to my macbooks smaller screen size. From here it states that tmux "limits the dimensions of a window to the smallest of each dimension across all the sessions to which the window is attached. If it did not do this there would be no sensible way to display the whole window area for all the attached clients." So there's no way to fix that I think.
Is there some easy command to move between the two terminal windows?
Command-backquote (⌘-`) cycles through the open windows in Terminal.
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
I want to run a series of unix commands, one after another. If any of these commands dies for whatever reason, subsequent commands should continue to run.
For instance, I have 3 commands called "setup", "long-running-job" and "teardown". If "long-running-job" finishes with whatever exit code, or dies unexpectedly, I want to make sure "teardown" gets run in any case.
Simply concatenating all commands with semicolons doesn't seem to work. I tried running touch test.txt; ping localhost; rm test.txt in macOS Terminal, closed the terminal tab while it's running, and found that the "test.text" didn't get removed.
If you want to make sure that even if your interactive window closes that your commands keep going and that all your command happen sequentially in the order you specify then use the method in this answer: https://unix.stackexchange.com/a/47231
Basically for the command line in your question
nohup sh -c 'touch test.txt; ping localhost; rm test.txt'
That means the hang up signal sent by closing the terminal is ignored.
Have you tried GNU parallel? Seems like the ideal tool for your needs.
$> parallel ::: setup long-running-job teardown
Parallel comes with tons of options to control halts, failures, jumps, retries, etc. See the manual and the tutorial for examples.
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 1 year ago.
Improve this question
I am connecting to a Linux system via PuTTY. I am using GNU screen.
Once I input a command on the screen, I am unable to create a new one or do anything else until this command gets completed. I have a feeling I am going about this all wrong.
When it says Ctrl + A, C, what does this mean? How do I get those keys listed on How To Use Linux Screen?
I am currently having to create multiple sessions of PuTTY.
Once you have executed the command screen you're now in a screen session. You can create new windows (think of them like tabs) and switch between them. To create a window, you use the command Ctrl-a c. This means:
Hold down Ctrl and a simultaneously (this tells screen you'd like to issue it the following command...)
Release the keys
Press c (create new window button)
This should create a new window in the screen session (you now have two).
To switch between windows you, again, use the Ctrl-a command followed by the number of the window you'd like to switch to. E.g., Ctrl-a 0 will take you home.
Ctrl-a " will list the windows you have active.
Ctrl-a k closes the current active window.
Ctrl-a d "Detaches" the screen session, you are moved back to the terminal where you invoked screen. Your screen session is still running in a background process, to return to it use Ctrl-a x.