2

Let me explain better. What is gonna happen if I run a command in Linux and before it's done and you could enter another command I close the terminal. Would it still do the command or not?

Ali_IT
  • 7,551
  • 8
  • 28
  • 44

4 Answers4

2

Generally, you must expect that closing your terminal will hangup your command. But fear not! Linux has a solution for that too!

To ensure that your command completes, use the nohup argument first. Simply place it before whatever you are trying to do:

nohup ./some_program
nohup ./do_a_thing -frx -file input_file.txt
nohup grep "something" giant_list_of_files/* > temp_file.txt

The nohup command stands for "no hangup" and it will ensure that the command you execute continues to run, even if you close your terminal.

john_science
  • 6,325
  • 6
  • 43
  • 60
1

It depends on the process and your environment (job control shell options, VNC, etc). But typically, no. The process will get a "hangup" signal (message) from the operating system, and upon receiving that, will quit.

The nohup command, for example, arranges for processes to ignore the hangup signal from the OS. There are many ways to achieve the same result.

theglauber
  • 28,367
  • 7
  • 29
  • 47
1

I would say it will abort att the status you are in just before the session close.

If you want to be sure to complete the job, you will need to use the nohup command.

http://en.wikipedia.org/wiki/Nohup

Read about nohups and daemons (-d)...

A good link is [link]What's the difference between nohup and a daemon?

Community
  • 1
  • 1
MrSimpleMind
  • 7,890
  • 3
  • 40
  • 45
0

Worth look at screen command, Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time.

Satish
  • 16,544
  • 29
  • 93
  • 149