Quantcast
Channel: Yazeed – QWORQS
Viewing all articles
Browse latest Browse all 93

Running the mv command in the background

$
0
0

One of the most annoying things that can happen to you is to disconnect your laptop from the network, then realize that there was a file moving job that was running, the command is going to get disconnected before mv gets the chance to delete the source files, the new copy is a hassle, i personally use rsync to continue such a copy with the delete source files flag

But it does not have to be this way, you can move the mv command to the background, the steps are simple

First, you need to hit CTRL+z to suspend the job, once suspended, you should see a job number in the suspend acknowledgement

Now, the next step is to disown the job, because right now, if you close your terminal window, the job will still be terminated

disown -h %1 (replace one with your own job number which may be 1)

Now to get the job running again but in the background

bg 1

That is it, you can now close (logout) your terminal window

So the summery
ctrl+z
disown -h %1
bg 1
logout

Now mind you, the output to stdout will not display (In most cases), you will need to use process status ps x to see the process.


Viewing all articles
Browse latest Browse all 93

Trending Articles