Tuesday, April 23, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1283  / 1 Year ago, sat, april 1, 2023, 9:06:33

Suppose that I want to run a Java program so I would type



java myProgram


and then suppose that it prints some output to the screen but takes a few hours to finish running. If I want to keep working on the same terminal while it runs, what is the command that I should use? I tried & at the end and it did not seem to work.


More From » command-line

 Answers
0

Just add a & after the command. This will make the command run on the background.



Notice that you will still get the output of it, so you may want to redirect the output to /dev/null or to some configuration file.



E.g. in order to redirect both stdout and stderr:



java myProgram > /dev/null 2>&1 &

[#24665] Sunday, April 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
emuralm

Total Points: 290
Total Questions: 111
Total Answers: 117

Location: China
Member since Thu, Sep 1, 2022
2 Years ago
;