How to start and run a process in the background and continue to use a terminal?

Whenever I start my browser I do
Code:
ssh -X -C jailuser@0.0.0.0 chrome
This starts my browser in a jail routed only through Wireguard.The issue is that I now have to have that terminal open with all the output of Chrome. How can I start a program, in this case chrome, as a background process? I want to start the program in the terminal but also be able to continue use or even close the terminal. I can remove the output by adding >/dev/null 2>/dev/null but the process is still connected to the terminal and the terminal is unusable. I have also tried to append an & at the end but this yields the same situation as above, a used terminal with no output.
 
You have to end your command line by &.

See sh(1) at "Background Commands".
As I said, ending the program with an and-sign* started the program but the console is blank. I do not regain control over the console however the process does not give out any output so it seems as if it is somewhat in the background. Notice that I run the program through ssh.

* wrote at-sign first, changed now.
 
Install 'screen' or 'tmux' on the local machine,
run the command inside one of them,
and detach the session or close terminal.
You able to reattach detached session whenever you want.

p.s.
& is NOT a at-sign @
 
& works perfectly through ssh.
I am unsure if you have actually understood anything I've written. I've already written two times now that appending & to the end of the command gives a blank output and I still do not have control over the terminal nor can I close it without the process being killed.

I get these comments from time to time and I am very curious as to how you were thinking. If I write in my original post that appending a & does not work and also respond with, in the second post, that it does not work, why comment that it works? What is supposed to happen the 12398 time I try it and do you think it will change because it works for you..? Why comment something I have adressed two times already?? I am not trying to be passive aggressive or whatever I authentically want to know because this is too common of an occurance to be a prank. Did I mislead you when I wrote that it does not work? Was I not strong enough in my lanauge in that I should have written something like "I have tested the & sign trick 12398 times in different combinations already and I am 101% percent sure it does not work. At all." So many questions.... such a confusing post comment...
 
I think you aren't clear . You confused people with the "at-sign".
Concerning the first message, I would begin by what you wrote at the end because this is the obvious answer.
 
I think you aren't clear . You confused people with the "at-sign".
Concerning the first message, I would begin by what you wrote at the end because this is the obvious answer.
I corrected my "at-sign" mistake already. I have tried your answer. I adressed it at the beginning. I adressed it as a response to your first comment. What is not clear? I have added it at the end of the command and I get a blank terminal. What more is there to say? Is it difficult to understand becasue I did not specify my screen dimensions? Because I omitted the exact version of my urxvt terminal?
There is literally nothing more to it, the terminal gets blank with "your" solution and the process terminates with the terminal. How is it "the obvious answer" when it does not work? I agree it is the go-to solution for these types of situation, however it does not work here hence why I made this post.
 
Try ssh -X jailuser@0.0.0.0 "chrome &" &

-C Requests compression of all data (including stdin, stdout,
stderr, and data for forwarded X11, TCP and UNIX-domain
connections). The compression algorithm is the same used by
gzip(1). Compression is desirable on modem lines and other slow
connections, but will only slow down things on fast networks.

The default value can be set on a host-by-host basis in the
configuration files; see the Compression option.
 
I corrected my "at-sign" mistake already. I have tried your answer. I adressed it at the beginning. I adressed it as a response to your first comment. What is not clear? I have added it at the end of the command and I get a blank terminal. What more is there to say? Is it difficult to understand becasue I did not specify my screen dimensions? Because I omitted the exact version of my urxvt terminal?
There is literally nothing more to it, the terminal gets blank with "your" solution and the process terminates with the terminal. How is it "the obvious answer" when it does not work? I agree it is the go-to solution for these types of situation, however it does not work here hence why I made this post.
You're right. I wasn't able to see what you have corrected after my second answer. And, no doubt, & isn't at all the solution. Furthermore, there are some evident proofs that I ain't smart enough to provide you any clue. This is noted.
 
You're right. I wasn't able to see what you have corrected after my second answer. And, no doubt, & isn't at all the solution. Furthermore, there are some evident proofs that I ain't smart enough to provide you any clue. This is noted.
Self deprication is not something I want to experience here on the forums, or anywhere really. I have not said you are not smart enough, stop with that attitude. I am authentically curious as to why, after I specified that something doesn't work, that you suggest it. I get this all the time, even when I write the correct term and everything. I guess you're just that type of person, like people who always come late. I am to this day very perplex that they are not ashamed for coming late every single time. That is not to say you should feel ashamed, just that you might just be a type of person who does not double check you're in the right thread, that when you reference you understood the reference, and so on. Most people double check and re-read and you obviously do not. That is OK. I just really wanted to know. Sorry for the tangent. Thanks for your input though :)

Also what do you mean by "& isn't at all the solution." Why did you suggest it then? What is the solution then, it seems as if you know when you write it like this.
 
Late? I already explained what is wrong with your problem description. So if you don't understand these explanations, that's and remains your problem, not mine.
 
Late? I already explained what is wrong with your problem description. So if you don't understand these explanations, that's and remains your problem, not mine.
The issue with my problem is that I explained the specific command I want to run in the background first? I gave a description of my issue first, before I introduced the issue. I ALWAYS get issues with people answering my question as if I asked something completely different when I do not start with the situation I am in. If I were to write "How does one run a process in the background from the terminal" and then write "btw I execute the command via ssh", then I would get answers that are not changed based on the fact that I run the command via SSH. This even though it might make a whole world of difference. Please mod remove Emrion's comments and my comments on his posts because Emrion clearly has not read my post as well as contributes with lots of negative energy and self depricating comments.
 
ssh -X jailuser@0.0.0.0 "chrome &" That's all there is to it. Note that the connection is terminated right after executing the command, so you're never going to see the output. Some applications are going to terminate because the SSH session does a SIGHUP, which would effective kill the application. There's a really old trick named nohup(1) you can use for this; ssh -X jailuser@0.0.0.0 "nohup chrome &"

 
ssh -X jailuser@0.0.0.0 "chrome &" That's all there is to it. Note that the connection is terminated right after executing the command, so you're never going to see the output. Some applications are going to terminate because the SSH session does a SIGHUP, which would effective kill the application. There's a really old trick named nohup(1) you can use for this; ssh -X jailuser@0.0.0.0 "nohup chrome &"

I believe the issue is that I still have a connection via SSH because using the & trick gets me stuck with:

Code:
ssh -X jailuser@0.0.0.0 "nohup chrome &"
Password for jailuser@browserjail:

Appending nohup changes nothing. Another issue is that when I do ssh -X jailuser@0.0.0.0 "nohup chrome &" & I get stuck because I cannot enter a password.
 
Simplest solution is to set up public/private keys so there's no password prompt.
 
In order to really disconnect a job from the current terminal and session, and make it run independently, one can use the daemon command, or one can run the job asynchronously with at (in that case the jobs output will be delivered by mail).
There are a few pitfalls in both approaches: daemon has a bunch of commandline options to figure out and properly set. at requires the user to have permission to use it, and, as it runs the command asynchronously, it needs all the PATHs and env-vars to be properly set.
By default, at will run the command at the next full 5 minutes, it can be configured to run a command at the next full minute in /etc/cron.d/at
 
Back
Top