Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have access to some Linux Workstations on which I run my C++ executable files from my Laptop but the problem is that each time I run a job from the terminal in my laptop I have to keep a terminal window for each job ... I need a way to submit the job to the Linux machine and see the result once only after the execution finishes ... I know that this can be done in FORTRAN executable by adding & at the end only and I tried it with: mpirun -np 20 ./a 200 1000000& and mpirun -np 20 ./a 200 1000000 & but non of them is working ...

Is there anyway to do the same in Linux with C++ ??

share|improve this question

migrated from Jan 9 '13 at 23:18

This question came from our site for professional and enthusiast programmers.

Have you looked at nohup? – jimmyb Jan 9 '13 at 22:08

Try adding nohup at the beginning of the command. This will protect the process from the SIGHUP signal (which can indicate that the owning terminal was closed), the default action for which is to terminate the process. For example:

nohup mpirun -np 20 ./a 200 1000000 &
share|improve this answer
Absolutely correct :). You know about the "&" part (to run the program in the background). "nohup" keeps your program from getting killed when you log off your terminal session. Finally, you might also wish to redirect output to a file you can read later: nohup mpirun -np 20 ./a 200 1000000 2>&1 mylog.txt & – paulsm4 Jan 9 '13 at 22:12

Look at the screen command.

man 1 screen
share|improve this answer
Unfortunately, "screen" probably won't help the OP if he wants to kill his terminal session. I believe "nohup" is the command he's looking for. IMHO... – paulsm4 Jan 9 '13 at 22:23
@paulsm4 I believe he means to run the command inside of screen. Then the terminal can exit after detaching from the screen instance, and the program will continue to run inside of screen, where it can be reattached to later. – cdhowie Jan 10 '13 at 0:01
screen will run detached, and you can reattach to it -- and OP did say he wants to see the results when it's done – jthill Jan 10 '13 at 0:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .