{"id":120,"date":"2011-06-30T07:13:17","date_gmt":"2011-06-30T07:13:17","guid":{"rendered":"http:\/\/tech.avant.net\/q\/?p=120"},"modified":"2012-12-25T22:40:40","modified_gmt":"2012-12-25T22:40:40","slug":"nohup-and","status":"publish","type":"post","link":"https:\/\/tech.avant.net\/q\/nohup-and\/","title":{"rendered":"nohup &#038;"},"content":{"rendered":"<p>I would like to run a script in the background and to keep running even after I log out.<\/p>\n<p>To run a command or script in the background use an ampersand, e.g.,<\/p>\n<pre class=\"sh_sh\">\r\n# .\/long-running-script.sh &\r\n<\/pre>\n<p>This is equivalent to suspending the process with Ctrl-Z, and then issuing <em>bg<\/em>,<\/p>\n<pre class=\"sh_sh\">\r\n# .\/long-running-script.sh\r\n^Z\r\n[1]+  Stopped                 .\/long-running-script.sh\r\n# bg\r\n[1]+ .\/long-running-script &\r\n#\r\n<\/pre>\n<p>However, to keep the command running even after logging out use <em>nohup<\/em>, e.g.,<\/p>\n<pre class=\"sh_sh\">\r\n# nohup .\/long-running-script.sh > .\/long-running-script.log &\r\n[1] 31163\r\n# nohup: ignoring input and redirecting stderr to stdout\r\n<\/pre>\n<p>To manage processes in the background, the commands <em>jobs<\/em>, <em>bg<\/em>, and <em>fg<\/em> are useful<\/p>\n<pre class=\"sh_sh\">\r\n# jobs\r\n[1]-  Running                 nohup long-running-script.sh > .\/long-running-script.log &\r\n[2]+  Running                 nohup some-other-script.sh &\r\n# fg 1\r\n...\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I would like to run a script in the background and to keep running even after I log out. To run a command or script in the background use an ampersand, e.g., # .\/long-running-script.sh &#038; This is equivalent to suspending the process with Ctrl-Z, and then issuing bg, # .\/long-running-script.sh ^Z [1]+ Stopped .\/long-running-script.sh # [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,14],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/120"}],"collection":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":5,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":733,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/posts\/120\/revisions\/733"}],"wp:attachment":[{"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.avant.net\/q\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}