3

I am connecting to my NAS over putty which is running linux on it.

I wanted to move a big directory from one location to another. Is it possible to keep the process running after I close the putty session ?

I am afraid that if I close putty the files will not be copied to the end ?

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
HightronicDesign
  • 699
  • 1
  • 9
  • 15

4 Answers4

6

Start your task with 'nohup' and put it in the background with '&', e.g.:

$ nohup mv /here /there &
$ exit

and it should continue running.

Moldova
  • 1,641
  • 10
  • 13
  • Thank you, i will try nohup. seems to be a really easy way – HightronicDesign Apr 20 '15 at 18:35
  • Hmm, i am getting this message and nothing is happening after that : nohup: ignoring input and appending output to 'nohup.out' – HightronicDesign Apr 20 '15 at 18:38
  • Since nohup disconnects the program from the terminal, it redirects any output into the file 'nohup.out'. Of course, there may not be any output in which case the file will be empty. But you should be able to run something like: ps ax | grep mv to see that your command is still running. – Moldova Apr 20 '15 at 19:09
2

I would suggest using screen for this.

Start a new screen,

screen -S <name of your screen>

and then you can perform your commands there, detach from the screen and re-attach to it at any time.

Detach by hitting the sequence

ctrl a d

and re-attach by typing

screen -r (or list the screens with screen -l).

Also have a look at Gnu screen survival guide.

Community
  • 1
  • 1
mattias
  • 2,079
  • 3
  • 20
  • 27
0

You can run it as a background process as follows:

nohup mv source target &

However, you will not be able to interact with the process.

EDIT: nohup is also required to keep it running after the shell exits.

mbsingh
  • 499
  • 10
  • 26
0

Using nohup would be best solution.

The following command in your terminal may help you out to run the script using nohup and redirect the output in your desired file.

General Syntax

nohup some_command &> nohup_log_file_name.out &

Example

nohup python script.py &> nohup_log_script.out & 

So, if you use the above command, you will be able to find the outputs of the command in a log file named nohup_log_script.out

Ariful Haque
  • 143
  • 1
  • 11