{"id":991,"date":"2020-08-08T12:54:22","date_gmt":"2020-08-08T12:54:22","guid":{"rendered":"http:\/\/www.tech-g.com\/?p=991"},"modified":"2025-07-24T03:21:14","modified_gmt":"2025-07-24T03:21:14","slug":"running-the-mv-command-in-the-background","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2020\/08\/08\/running-the-mv-command-in-the-background\/","title":{"rendered":"Running the mv command in the background"},"content":{"rendered":"\n<p>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<\/p>\n\n\n\n<p>But it does not have to be this way, you can move the mv command to the background, the steps are simple<\/p>\n\n\n\n<p>First, to suspend the job, you need to hit CTRL+z , once suspended, you should see a job number in the suspend acknowledgement<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">CTRL+Z<\/pre>\n\n\n\n<p>Now, the next step is to disown the job, because right now, if you close your terminal window, the job will still be terminated<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>disown -h %1 (replace one with your own job number which may be 1)<\/code><\/pre>\n\n\n\n<p>Now to get the job running again but in the background<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bg 1<\/code><\/pre>\n\n\n\n<p>That is it, you can now close (logout) your terminal window<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">So the summery\nctrl+z\ndisown -h %1\nbg 1\nlogout<\/pre>\n\n\n\n<p>Now mind you, the output to stdout will not display (In most cases), you will need to use process status <code>ps x<\/code> to see the process.<\/p>\n\n\n\n<p>If you want to bring back the command into the foreground, all you need to do is execute the command jobs (to find the ID), then run the command fg 1 (if it was job number one), then to hide it again, you can ctrl+z then bg 1 again (No need to disown it this time)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-991","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":8,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":4752,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions\/4752"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}