{"id":130301,"date":"2025-06-26T04:41:35","date_gmt":"2025-06-26T04:41:35","guid":{"rendered":"\/tutorials\/?p=130301"},"modified":"2026-03-10T09:26:15","modified_gmt":"2026-03-10T09:26:15","slug":"nohup-command-in-linux","status":"publish","type":"post","link":"\/ca\/tutorials\/nohup-command-in-linux","title":{"rendered":"How to use the nohup command in Linux"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><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<\/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=\"\/ca\/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\"><figure data-wp-context='{\"imageId\":\"69e20289086e6\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"198\" 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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-command-version-on-terminal-1024x198.png\" alt=\"The nohup version on the terminal\" class=\"wp-image-130302\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><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=\"\/ca\/vps-hosting\">Linux virtual private server (VPS) from Hostinger<\/a>.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ca\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\"  sizes=\"auto, (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\"><figure data-wp-context='{\"imageId\":\"69e202890c67a\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"114\" 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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/06\/terminal-prints-nohup-process-output-from-the-default-file-1024x114.png\" alt=\"The terminal prints the nohup process's output from the default file\" class=\"wp-image-130303\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><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\"><figure data-wp-context='{\"imageId\":\"69e202890eaa5\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"133\" 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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-redirects-output-to-another-file-1024x133.png\" alt=\"nohup redirects a process's output to another file\" class=\"wp-image-130304\" style=\"width:840px;height:auto\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><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><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\"><figure data-wp-context='{\"imageId\":\"69e2028911404\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"73\" 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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/06\/nohup-background-process-order-and-id-1024x73.png\" alt=\"A nohup background process's order and ID number\" class=\"wp-image-130305\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><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=\"\/ca\/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\"><figure data-wp-context='{\"imageId\":\"69e2028913c67\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" 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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/06\/ps-checks-nohup-process.png\" alt=\"The ps command checks a nohup process's status\" class=\"wp-image-130306\"  sizes=\"auto, (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=\"\/ca\/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\"><figure data-wp-context='{\"imageId\":\"69e20289163ea\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"107\" 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=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2025\/06\/lsof-checks-all-nohup-processes-1024x107.png\" alt=\"The lsof command checks all nohup processes from its output file\" class=\"wp-image-130307\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><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=\"\/ca\/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=\"\/ca\/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=\"\/ca\/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=\"\/ca\/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 closes. This is essential for system administrators, as it helps prevent long-running tasks like builds or monitoring from being interrupted. Using the nohup command is straightforward: simply enter it in your system&rsquo;s terminal, followed by [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/nohup-command-in-linux\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":0,"comment_status":"open","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":[22699],"tags":[],"class_list":["post-130301","post","type-post","status-publish","format-standard","hentry","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\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/130301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=130301"}],"version-history":[{"count":3,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/130301\/revisions"}],"predecessor-version":[{"id":140992,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/130301\/revisions\/140992"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=130301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=130301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=130301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}