Difference between revisions of "POSIX/nohup"

From Adam Meola - wiki
Jump to navigation Jump to search
(Created page with "==Definition:== The command to ignore the HUP (hangup) signal. It prevents the process from exiting when the terminal or ssh session is closed. ==How to use it== ===Start...")
 
Line 23: Line 23:
 
:: <code>kill -9 `cat ./process.pid`</code>
 
:: <code>kill -9 `cat ./process.pid`</code>
 
::* This will read the "process.pid" file, and use the value previously saved to kill that process.
 
::* This will read the "process.pid" file, and use the value previously saved to kill that process.
 +
 +
 +
{{Infobox settlement
 +
|official_name    = City of Hamilton
 +
...truncated...
 +
|leader_title      = [[Mayor]]
 +
|leader_name      = [[Fred Eisenberger]]
 +
|leader_title1    = [[City Council]]
 +
|leader_name1      = [[Hamilton City Council]]
 +
|leader_title2    = [[Member of Parliament (Canada)|MPs]]
 +
|leader_name2      =
 +
{{Collapsible list
 +
  |framestyle=border:none; padding:0; <!--Hides borders and improves row spacing-->
 +
  |title=List of MPs
 +
  |1=[[Dean Allison]] |2=[[Chris Charlton]] |3=[[David Christopherson]] |4=[[Wayne Marston]] |5=[[David Sweet]]
 +
}}
 +
|leader_title3    = [[Member of Provincial Parliament (Ontario)|MPPs]]
 +
|leader_name3      =
 +
{{Collapsible list
 +
  |framestyle=border:none; padding:0; <!--as above-->
 +
  |title=List of MPPs
 +
  |1=[[Marie Bountrogianni]] |2=[[Andrea Horwath]] |3=[[Judy Marsales]] |4=[[Ted McMeekin]] |5=[[Jennifer Mossop]]
 +
}}
 +
|established_title = [[Municipal corporation|Incorporated]]
 +
|established_date  = June 9, 1846
 +
(...etc...)
 +
}}

Revision as of 02:42, 29 August 2020

Definition:

The command to ignore the HUP (hangup) signal.

It prevents the process from exiting when the terminal or ssh session is closed.

How to use it

Start a process

  • In the terminal:
    • cd to the directory you'd like to start the process in.
    • Run:
nohup [commandYoudLikeToKeepRunningAfterClosed] > /dev/null 2>&1 & echo $! > process.pid
  • This will start the process, and save a "process.pid" (process id number) file to the directory
  • This is so that your filesystem has a record of which process is running, for use later.

Stop a process

  • In the terminal:
    • cd to the directory that the applicable process was started in.
    • Run:
kill -9 `cat ./process.pid`
  • This will read the "process.pid" file, and use the value previously saved to kill that process.


Template:Infobox settlement