nohup 명령어 (AIX 5.3·6.1)

핵심 정리

  • 행업 신호(SIGHUP)를 무시하게 해서 명령을 실행합니다. 로그오프한 뒤에도 명령이 계속 돌게 할 때 씁니다.
  • 백그라운드로 돌리려면 끝에 &를 붙입니다(nohup 명령 &).
  • 출력을 재지정하지 않으면 nohup.out에 씁니다.
  • -p pid는 이미 실행 중인 프로세스가 SIGHUP을 무시하게 바꿉니다. 이때 출력은 nohup.out으로 가지 않습니다.
  • 종료 상태는 실행한 명령의 것이며, 명령을 찾았지만 실행할 수 없으면 126, 찾을 수 없거나 nohup 오류면 127입니다.
  • AIX 5.3과 6.1 문서의 내용이 같습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (두 버전 내용 같음)
원문 IBM Commands Reference — 5.3 Volume 4, 6.1 Volume 4
파일 /usr/bin/nohup, 출력 파일 nohup.out
관련 명령어 nice, sh, csh

목적

행업 신호를 무시하고 명령을 실행합니다.

영어 원문

Runs a command without hangups.

구문

text
nohup { -p pid | Command [ Arg ... ] [ & ] }

설명

nohup 명령은 Command 매개변수로 지정한 명령을 Arg 매개변수와 함께 실행하면서 모든 행업(SIGHUP) 신호를 무시하게 하거나, -p 옵션으로 지정한 프로세스가 모든 행업 신호를 무시하도록 바꿉니다.

nohup으로 로그오프한 뒤에도 프로그램을 백그라운드로 돌릴 수 있습니다. 백그라운드로 실행하려면 명령 끝에 &(앰퍼샌드)를 붙입니다.

참고: -p pid와 Command는 함께 지정할 수 없습니다. -p pid를 쓰면 지정한 프로세스의 출력은 nohup.out으로 재지정되지 않습니다.

영어 원문

The nohup command runs the command specified by the Command parameter and any related Arg parameters, ignoring all hangup (SIGHUP) signals or modifies the process specified with -p option to ignore all hangup (SIGHUP) signals.

The nohup command can also be used to run programs in the background after logging off. To run a nohup command in the background, add an & (ampersand) to the end of the command.

Note: -p pid and Command can not be specified together. When -p pid is used, the output of the specified process will not be re-directed to nohup.out.

플래그

플래그 설명
-p pid pid는 실행 중인 프로세스의 ID입니다. 그 프로세스가 모든 행업(SIGHUP) 신호를 무시하도록 바꿉니다.
영어 원문
  • -p pid — pid is the process-id of a running process. The nohup command modifies the specified process, to ignore all hangup (SIGHUP) signals.

종료 상태

값 뜻
126 Command로 지정한 명령을 찾았지만 실행할 수 없었습니다.
127 nohup에서 오류가 났거나, Command로 지정한 명령을 찾을 수 없었습니다.

그 밖에는 Command로 지정한 명령의 종료 상태가 nohup의 종료 상태입니다.

영어 원문

This command returns the following exit values:

  • 126 — The command specified by the Command parameter was found but could not be invoked.
  • 127 — An error occurred in the nohup command or the command specified by the Command parameter could not be found.

Otherwise, the exit status of the nohup command is that of the command specified by the Command parameter.

예제

  1. 로그오프한 뒤에도 백그라운드로 명령을 실행합니다.
bash
nohup find / -print &

다음과 같이 표시됩니다.

text
670
$ Sending output to nohup.out

프로세스 ID는 &가 시작한 백그라운드 프로세스의 것입니다. Sending output to nohup.out 메시지는 find / -print의 출력이 nohup.out에 있다는 뜻입니다. 이 메시지가 보이면 find가 아직 돌고 있어도 로그오프할 수 있습니다.

  1. 백그라운드로 실행하며 표준 출력을 다른 파일로 재지정합니다. find / -print의 출력을 filenames 파일에 저장하며, 이제 프로세스 ID와 안내 문구만 표시됩니다.
bash
nohup find / -print >filenames &

nohup이 명령을 시작하는 데 잠깐 걸리므로 바로 로그오프하지 말고 조금 기다립니다. 너무 빨리 로그오프하면 명령이 아예 실행되지 않을 수 있습니다. 명령이 시작된 뒤에는 로그오프해도 영향이 없습니다.

  1. 명령 여러 개를 실행하려면 셸 프로시저를 씁니다. 예를 들어 다음 셸 프로시저를 nnfmath1 파일로 저장했다면,
bash
neqn math1 | nroff > fmath1

다음 명령으로 nnfmath1의 모든 명령을 nohup으로 실행할 수 있습니다.

bash
nohup sh nnfmath1
  1. nnfmath1에 실행 권한을 주었으면 다음 명령도 같습니다.
bash
nohup nnfmath1
  1. nnfmath1을 백그라운드로 실행합니다.
bash
nohup nnfmath1 &
  1. nnfmath1을 Korn 셸로 실행합니다.
bash
nohup ksh nnfmath1
  1. 실행 중인 프로세스가 모든 행업 신호를 무시하게 합니다.
bash
nohup -p 161792

관련 명령어: nice, csh, sh

영어 원문
  1. To run a command in the background after you log off, enter: $ nohup find / -print &

After you enter this command, the following is displayed: 670 $ Sending output to nohup.out

The process ID number changes to that of the background process started by & (ampersand). The message Sending output to nohup.out informs you that the output from the find / -print command is in the nohup.out file. You can log off after you see these messages, even if the find command is still running.

  1. To run a command in the background and redirect the standard output to a different file, enter: $ nohup find / -print >filenames &

This example runs the find / -print command and stores its output in a file named filenames. Now only the process ID and prompt are displayed: 677 $

Wait before logging off because the nohup command takes a moment to start the command specified by the Command parameter. If you log off too quickly, the command specified by the Command parameter may not run at all. Once the command specified by the Command parameter starts, logging off does not affect it.

  1. To run more than one command, use a shell procedure. For example, if you write the shell procedure: neqn math1 | nroff > fmath1

and name it the nnfmath1 file, you can run the nohup command for all of the commands in the nnfmath1 file with the command: nohup sh nnfmath1

  1. If you assign execute permission to the nnfmath1 file, you get the same results by issuing the command: nohup nnfmath1

  2. To run the nnfmath1 file in the background, enter:

nohup nnfmath1 &

  1. To run the nnfmath1 file in the Korn shell, enter:
nohup ksh nnfmath1
  1. To make a running process ignore all hangup signals, enter:
nohup -p 161792

Related reference:

  • nice Command

Related information:

  • csh command
  • sh command
  • signal command

리눅스(GNU)와 다른 점

항목 AIX 5.3·6.1 GNU nohup
-p pid 실행 중인 프로세스에 적용 없음(bash의 disown -h를 씀)
출력 파일 nohup.out 같음(현재 디렉터리에 못 쓰면 $HOME/nohup.out)