{"id":108,"date":"2024-12-14T15:52:55","date_gmt":"2024-12-14T15:52:55","guid":{"rendered":"https:\/\/w3buddy.com\/?p=108"},"modified":"2026-01-15T13:12:24","modified_gmt":"2026-01-15T07:42:24","slug":"how-to-keep-processes-running-in-the-background-with-nohup","status":"publish","type":"post","link":"https:\/\/w3buddy.com\/blog\/how-to-keep-processes-running-in-the-background-with-nohup\/","title":{"rendered":"How to Keep Processes Running in the Background with nohup"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>nohup<\/code> command, short for &#8220;no hang up,&#8221; is a useful tool in Unix-like systems that allows you to run commands or scripts in the background, even if you log out or close the terminal. This is especially helpful for long-running tasks that need to continue after you disconnect.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to Use nohup<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some common scenarios where <code>nohup<\/code> is beneficial:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\"># 1. Oracle Data Pump Export (expdp)\nnohup expdp '\"\/ as sysdba\"' DIRECTORY=dump_dir DUMPFILE=export.dmp LOGFILE=export.log &amp;\n\n# 2. Oracle Data Pump Import (impdp)\nnohup impdp '\"\/ as sysdba\"' DIRECTORY=dump_dir DUMPFILE=import.dmp LOGFILE=import.log &amp;\n\n# 3. Zipping Files\nnohup zip -r archive.zip \/path\/to\/directory > zip.log 2>&amp;1 &amp;\n\n# 4. Running a Shell Script (.sh)\nnohup bash script.sh > script.log 2>&amp;1 &amp;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Key Points to Remember<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>&amp;<\/code>: Runs the command in the background, allowing you to use the terminal for other tasks.<\/li>\n\n\n\n<li><code>> file.log 2>&amp;1<\/code>: Redirects both standard output and error messages to <code>file.log<\/code>, capturing all output.<\/li>\n\n\n\n<li><code>nohup.out<\/code>: If no output redirection is specified, the output is saved to the default <code>nohup.out<\/code> file.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Why Use nohup?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using <code>nohup<\/code> ensures that processes continue running even after you disconnect from the terminal. It\u2019s an essential tool for system administrators and developers handling long-running tasks, providing a reliable way to execute background jobs without constant monitoring.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The nohup command, short for &#8220;no hang up,&#8221; is a useful tool in Unix-like systems that allows you to run commands or scripts in the background, even if you log out or close the terminal. This is especially helpful for long-running tasks that need to continue after you disconnect. How to Use nohup Here are [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"googlesitekit_rrm_CAowu461DA:productID":"","footnotes":""},"categories":[1225],"tags":[],"class_list":["post-108","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":2,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":1431,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/posts\/108\/revisions\/1431"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}