sample.sh
[linuxstudy@xxxx ~]$ cat sample.sh
#!/bin/sh
while true; do
sleep 3s
echo "i'm looping"
done
linuxstudy@xxxx ~]$ nohup ./sample.sh & //nohupでシェルを起動
[1] 23484
nohup: 入力を無視し、出力を `nohup.out' に追記します
[linuxstudy@xxxx ~]$ less nohup.out
[linuxstudy@xxxx ~]$ jobs
[1]+ 実行中 nohup ./sample.sh &
[linuxstudy@xxxx ~]$ fg %1
nohup ./sample.sh
^C
[linuxstudy@xxxx ~]$ jobs
[linuxstudy@xxxx ~]$ cat nohup.out //標準出力ではなくnohup.outに出力されている
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
i'm looping
NOHUP(1) User Commands NOHUP(1)
NAME
nohup - run a command immune to hangups, with output to a non-tty
SYNOPSIS
nohup COMMAND [ARG]...
nohup OPTION
DESCRIPTION
Run COMMAND, ignoring hangup signals.
--help display this help and exit
--version
output version information and exit
If standard input is a terminal, redirect it from /dev/null. If standard output is a terminal, append out‐
put 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'.
NOTE: your shell may have its own version of nohup, which usually supersedes the version described here.
Please refer to your shell's documentation for details about the options it supports.
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report nohup translation bugs to
<http://translationproject.org/team/>
AUTHOR
Written by Jim Meyering.
COPYRIGHT
Copyright © 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent
permitted by law.
SEE ALSO
The full documentation for nohup is maintained as a Texinfo manual. If the info and nohup programs are
properly installed at your site, the command
info coreutils 'nohup invocation'
should give you access to the complete manual.
GNU coreutils 8.22 November 2020 NOHUP(1)```