{"id":130301,"date":"2025-06-26T04:41:35","date_gmt":"2025-06-26T04:41:35","guid":{"rendered":"\/tutorials\/?p=130301"},"modified":"2025-12-22T12:46:47","modified_gmt":"2025-12-22T12:46:47","slug":"nohup-command-in-linux","status":"publish","type":"post","link":"\/tutorials\/nohup-command-in-linux","title":{"rendered":"How to use the nohup command in Linux"},"content":{"rendered":"<p>The <strong>no hang up<\/strong> or <strong>nohup<\/strong> command allows processes in your Linux system to keep running even after the terminal closes. This is essential for system administrators, as it helps prevent long-running tasks like builds or monitoring from being interrupted.<\/p><p>Using the nohup command is straightforward: simply enter it in your system&rsquo;s terminal, followed by the process you want to run continuously. Beyond basic usage, you can use it to run tasks in the background and redirect output to a specific file.<\/p><p>In this article, we&rsquo;ll cover usage of the nohup command in more detail, as well as its real-world applications.<\/p><p>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-does-the-nohup-command-do\"><strong>What does the nohup command do?<\/strong><\/h2><p>Linux sends the <strong>hang-up signal (SIGHUP)<\/strong> to terminate all processes in the shell when you close the terminal. This can also happen in a remote system due to connectivity issues.<\/p><p>To restart the processes, you must manually reenter the <a href=\"\/tutorials\/linux-commands\">Linux commands<\/a> or scripts. This can be tedious and time-consuming if there are many long-running tasks.<\/p><p>The nohup command blocks the processes from receiving the SIGHUP signal, keeping them running even after terminal exit.<\/p><h3 class=\"wp-block-heading\" id=\"h-what-are-the-use-cases-for-nohup\"><strong>What are the use cases for nohup?<\/strong><\/h3><p>The nohup command is helpful for maintaining continuous tasks. Here are some examples of popular use cases for system administrators and developers:<\/p><ul class=\"wp-block-list\">\n<li><strong>Maintaining long-running processes<\/strong>. Long-running jobs like data processing or software builds take a very long time and require a complete restart when interrupted. The nohup command prevents them from stopping after logout or SSH disconnection.&nbsp;<\/li>\n\n\n\n<li><strong>Server maintenance<\/strong>. The use of nohup allows server maintenance scripts &ndash; like log rotation, updates, or cleanup tasks &ndash; to run independently of an administrator&rsquo;s session. This keeps the system functioning reliably.&nbsp;<\/li>\n\n\n\n<li><strong>Running automatic backups<\/strong>. You can use nohup to run scripts that regularly back up your server data even when you are not logged into the shell. This is a simple way to ensure data integrity during long or unattended operations.<\/li>\n\n\n\n<li><strong>Automation and scheduled tasks.<\/strong> Scheduled tasks like deployments or report generation can run independently using nohup. This allows developers and sysadmins to run persistent scripts without setting up a full service manager like systemd.&nbsp;<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-nohup-command-syntax\"><strong>nohup command syntax<\/strong><\/h2><p>The nohup command syntax is structured as follows:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup command [options]<\/pre><p>Here&rsquo;s the breakdown of the syntax:<\/p><ul class=\"wp-block-list\">\n<li><strong>nohup<\/strong> &ndash; the command name, instructing the terminal to enable <strong>no hang up<\/strong>.<\/li>\n\n\n\n<li><strong>command<\/strong> &ndash; the command, script, or process you want nohup to run continuously.<\/li>\n\n\n\n<li><strong>[options]<\/strong> &ndash; optional flags for modifying the nohup command behavior.<\/li>\n<\/ul><p>The nohup command options are as follows:<\/p><ul class=\"wp-block-list\">\n<li><strong>&ndash;help<\/strong> &ndash; displays the nohup command manual in your system&rsquo;s shell.<\/li>\n\n\n\n<li><strong>&ndash;version<\/strong> &ndash; outputs the nohup command version, useful for checking if it&rsquo;s installed and up-to-date.<\/li>\n\n\n\n<li><strong>&amp;<\/strong> &ndash; an operator for running the command, script, or process in the background instead of the main shell.<\/li>\n<\/ul><p>You can run the following command to check the nohup version:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup --version<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e79fdbe0014\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"282\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal.png\/public\" alt=\"The nohup version on the terminal\" class=\"wp-image-130302\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h2 class=\"wp-block-heading\" id=\"h-how-to-use-the-nohup-command\"><strong>How to use the nohup command?<\/strong><\/h2><p>Here are several nohup command examples in a real-world scenario. To follow along, open your system&rsquo;s terminal or the <strong>browser terminal <\/strong>if you use a <a href=\"\/vps-hosting\">Linux virtual private server (VPS) from Hostinger<\/a>.<\/p><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/public\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-running-a-process-with-nohup\"><strong>Running a process with nohup<\/strong><\/h3><p>To run a process indefinitely, use the basic nohup command syntax as follows:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup process<\/pre><p>For example, enter the following to run a simple Bash shell script that prints a <strong>Hello world!<\/strong> message:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh<\/pre><p>After running nohup, you can see the process&rsquo;s output from the <strong>nohup.out<\/strong> file. Check its content using the following <strong>cat<\/strong> command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat nohup.out<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e79fdbe1bcf\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1276\" height=\"142\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file.png\/public\" alt=\"The terminal prints the nohup process's output from the default file\" class=\"wp-image-130303\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file.png\/w=1276,fit=scale-down 1276w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1276px) 100vw, 1276px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-redirecting-output-to-files\"><strong>Redirecting output to files<\/strong><\/h3><p>To save the output of processes run using nohup to another file, use the redirection operator (<strong>&gt;<\/strong>) like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh &gt; file.txt<\/pre><p>Check the saved output by printing the file&rsquo;s content using the <strong>cat<\/strong> command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat file.txt<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e79fdbe2488\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img decoding=\"async\" width=\"1048\" height=\"136\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file.png\/public\" alt=\"nohup redirects a process's output to another file\" class=\"wp-image-130304\" style=\"width:840px;height:auto\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file.png\/w=1048,fit=scale-down 1048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1048px) 100vw, 1048px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Note that the above redirection operator will overwrite the file with the new output. If you want to append the existing content, use the following operator:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh &gt;&gt; file.txt<\/pre><p>In some cases, nohup doesn&rsquo;t automatically redirect errors, meaning you must do it manually. For example, the following will log the process&rsquo;s output and errors to <strong>file.txt<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh &gt; file.txt 2&gt;&amp;1<\/pre><p>Here&rsquo;s the breakdown of the command:<\/p><ul class=\"wp-block-list\">\n<li><strong>nohup .\/script.sh &gt; file.txt<\/strong> &ndash; the command for redirecting the nohup process output to <strong>file.txt<\/strong>.&nbsp;<\/li>\n\n\n\n<li><strong>2<\/strong> &ndash; the identifier for<strong> stderr <\/strong>or <strong>errors<\/strong> from the process.<\/li>\n\n\n\n<li><strong>1<\/strong> &ndash; the identifier for<strong> stdout<\/strong> or <strong>output<\/strong> from the process.<\/li>\n\n\n\n<li><strong>&gt;&amp;<\/strong> &ndash; the output redirection that writes <strong>errors (2)<\/strong> to wherever the <strong>output (1)<\/strong> will go, in this case, <strong>file.txt<\/strong>.<\/li>\n<\/ul><p>In the Bash shell, the command can also look like the following:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh &amp;&gt; file.txt<\/pre><p>If you want to append errors, simply use the <strong>&gt;&gt;<\/strong> redirection instead of <strong>&gt;<\/strong> like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh &gt;&gt; file.txt 2&gt;&amp;1<\/pre><p>You can also save the nohup process&rsquo;s output and errors in separate files like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup .\/script.sh &gt; output.txt &gt; errors.txt<\/pre><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Mind the gap<\/h4>\n                    <p>Note that there&rsquo;s no space between the redirection operator and <strong>stdout<\/strong> or <strong>stderr<\/strong>.<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-running-processes-in-the-background\"><strong>Running processes in the background<\/strong><\/h3><p>By default, the nohup command will run a process in the main terminal shell. This means that you must terminate it to run other utilities, which can be problematic if you have multiple tasks.<\/p><p>As a workaround, nohup provides the <strong>&amp;<\/strong> option to let you run the process in the background. This enables you to use the main shell for other tasks even when the process is running. Here&rsquo;s how the command looks:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nohup process &amp;<\/pre><p>When running nohup in the background, your terminal will give an output similar to this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[1] 1234<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e79fdbe3028\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1044\" height=\"74\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id.png\/public\" alt=\"A nohup background process's order and ID number\" class=\"wp-image-130305\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id.png\/w=1044,fit=scale-down 1044w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1044px) 100vw, 1044px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>The <strong>[1] <\/strong>placeholder represents the background process&rsquo;s order in the current terminal shell. For example,<strong> [1]<\/strong> means the first, <strong>[2]<\/strong> is the second, and so on.<\/p><p>Meanwhile, <strong>1234<\/strong> is the job&rsquo;s <strong>process ID<\/strong> (<strong>PID<\/strong>). This information is essential for identifying and stopping the process, which we&rsquo;ll explain later.<\/p><h3 class=\"wp-block-heading\" id=\"h-checking-the-nohup-process-status\"><strong>Checking the nohup process status<\/strong><\/h3><p>To <a href=\"\/tutorials\/how-to-list-processes-in-linux\">check running processes<\/a> started using nohup, use the <strong>ps <\/strong>command followed by their PID. Here&rsquo;s the command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ps -p PID<\/pre><p>The process is running if the terminal outputs the executed command or script name.<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e79fdbe397c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"804\" height=\"108\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/ps-checks-nohup-process.png\/public\" alt=\"The ps command checks a nohup process's status\" class=\"wp-image-130306\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/ps-checks-nohup-process.png\/w=804,fit=scale-down 804w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/ps-checks-nohup-process.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/ps-checks-nohup-process.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/ps-checks-nohup-process.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>If you forget the PID, use <strong>pgrep<\/strong> to check a nohup process&rsquo;s status using its command or script name, like so:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pgrep -a process-name<\/pre><p>For example, enter the following if you want to check if the <a href=\"\/tutorials\/linux-sleep-command\">sleep command<\/a> is running:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pgrep -a sleep<\/pre><p>If you forget both the PID and process name, use the<strong> lsof<\/strong> command to check jobs that use the nohup output file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">lsof | grep nohup.out<\/pre><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e79fdbe42b6\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"153\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes.png\/public\" alt=\"The lsof command checks all nohup processes from its output file\" class=\"wp-image-130307\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes.png\/w=1460,fit=scale-down 1460w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Your terminal will list commands and scripts run using nohup, along with their PID. Remember to replace <strong>nohup.out<\/strong> if you redirected the output to another file.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-manage-nohup-processes\"><strong>How to manage nohup processes<\/strong><\/h2><p>To stop a nohup process that is running in the main shell, hit the<strong> Ctrl + C<\/strong> shortcut on your keyboard to send the <strong>SIGTERM<\/strong> signal &ndash; a graceful termination method that allows the task to finish first before stopping.<\/p><p>If you run a nohup task in the background, the only way to stop it is to use the<strong> kill <\/strong>command, which lets you <a href=\"\/tutorials\/how-to-kill-a-process-in-linux\">kill a process in Linux<\/a> using its PID. The syntax is as follows:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kill PID<\/pre><p>For example, here&rsquo;s a command to terminate a process with a PID of <strong>1234<\/strong>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kill 1234<\/pre><p>By default, the kill command will send the <strong>SIGTERM<\/strong> signal, which may not be enough to stop an unresponsive process. In this case, use the <strong>SIGKILL<\/strong> signal to forcefully terminate the task.<\/p><p>To pass the SIGKILL termination signal using the kill command, add the <strong>-9<\/strong> option:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">kill -9 PID<\/pre><p>Note that you can&rsquo;t bring nohup processes from the background to the foreground or the main shell. This is because nohup isn&rsquo;t interactive and doesn&rsquo;t register your tasks as jobs, which are manageable using the <strong>fg<\/strong> or <strong>bg<\/strong> command.<\/p><p>If you wish to interact with background processes, run them using alternative tools that we&rsquo;ll explain in the next section.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-are-the-alternatives-to-nohup\"><strong>What are the alternatives to nohup?<\/strong><\/h2><p>In addition to nohup, Linux has other tools that let you run commands in the background. Here are some popular options.<\/p><p><strong>GNU Screen<\/strong><\/p><p>The <a href=\"\/tutorials\/how-to-install-and-use-linux-screen\/\">GNU Screen<\/a> is a terminal multiplexer that enables you to create virtual shell sessions that remain active in the background.<\/p><p>Since Screen is interactive, it&rsquo;s an excellent alternative to nohup if you wish to manage and switch between processes easily.<\/p><p><strong>tmux<\/strong><\/p><p><a href=\"\/tutorials\/how-to-use-tmux\">Terminal multiplexer (tmux)<\/a> is a more modern and user-friendly Screen alternative. This tool has features like better window splitting and an intuitive user interface, which makes it easier to use than Screen.<\/p><p>However, tmux&rsquo;s deeper functionality also makes it more challenging to learn than Screen.<\/p><p><strong>systemd-run<\/strong><\/p><p>The systemd-run command runs processes as a service, which is more reliable because your tasks have better isolation, dependency handling, and failover mechanisms.<\/p><p>However, systemd-run is only available in systemd-based operating systems. It&rsquo;s also more complicated to set up than nohup since you must configure the process as a service.<\/p><p><strong>Docker<\/strong><\/p><p>Docker is a containerization tool for running processes in dedicated environments, with their own resource constraints and software setup. Since tasks can run independently from others, it provides a high level of isolation and reliability.<\/p><p>Docker is excessive for simple tasks that you usually run with nohup because it can be challenging to set up and manage. It&rsquo;s ideal for complex processes, like setting up a consistent deployment pipeline.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\"><strong>Conclusion<\/strong><\/h2><p>The nohup command is a handy tool for keeping simple processes running in the background. It is especially useful when working with a remote server where a connection issue may end the terminal session.<\/p><p>Note that nohup is most suitable for simple, one-off processes. For more complex tasks, consider an alternative tool with interactive functionality like <strong>Screen<\/strong>.<\/p><p>Once you&rsquo;ve grasped the purpose of the nohup command, try it on your system&rsquo;s terminal or in Hostinger&rsquo;s VPS <strong>browser terminal<\/strong>. <a href=\"\/vps-hosting\">Hostinger&rsquo;s VPS hosting<\/a> also gives you the option to ask <strong>Kodee, an AI assistant,<\/strong> for help if you need it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The no hang up or nohup command allows processes in your Linux system to keep running even after the terminal [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/nohup-command-in-linux\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":121619,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How do you use the nohup command in Linux?","rank_math_description":"The nohup command allows Linux processes to keep running even after terminal closure. Explore its syntax and usage in this guide.","rank_math_focus_keyword":"nohup command","footnotes":""},"categories":[22648,22644],"tags":[],"class_list":["post-130301","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/nohup-command-in-linux","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/nohup-command-in-linux","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/130301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=130301"}],"version-history":[{"count":2,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/130301\/revisions"}],"predecessor-version":[{"id":138101,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/130301\/revisions\/138101"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media\/121619"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=130301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=130301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=130301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}