출력 없이 현재 디렉터리에서 프로세스를 실행하고 이를 거부하는 한 줄의 코드가 있습니까?

출력 없이 현재 디렉터리에서 프로세스를 실행하고 이를 거부하는 한 줄의 코드가 있습니까?

나는 매우 간단한 일을 하려고 합니다.

$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'

서브셸에서 코드 줄을 실행하고, 주어진 폴더에서 주어진 스크립트를 실행하고, 출력을 지우고 백그라운드로 보내는 방법은 무엇입니까?

답변1

문제는 &및 을 둘 다 사용하고 있다는 것입니다 ;. 둘 다 명령 종료자이므로 동시에 사용할 수 없습니다. 수정 사항의 예는 다음과 같습니다.

( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )

답변2

이것북면유틸리티는 여러분이 찾고 있는 것에 맞게 설계되었습니다.

Usage: nohup COMMAND [ARG]...
  or:  nohup OPTION
Run COMMAND, ignoring hangup signals.

If standard input is a terminal, redirect it from /dev/null.
If standard output is a terminal, append output to 'nohup.out' if possible,
'$HOME/nohup.out' otherwise.
If standard error is a terminal, redirect it to standard output.
To save output to FILE, use 'nohup COMMAND > FILE'.

관련 정보