Nohupインタラクティブシェルスクリプトを使用するには?

Nohupインタラクティブシェルスクリプトを使用するには?

私のスクリプトには2つのコマンドライン引数といくつかの質問があります。その後、スクリプトは独自に実行され、次のようにしてコマンドライン引数を渡します。

-bash-3.2$ nohup ./Script.sh 21 7
nohup: appending output to `nohup.out'

-bash-3.2$

とにかくnohupを使ってこれらの質問に答えを追加したいですか?

ベストアンサー1

nohup使用するdisown代わりに

はい

$ more a.bash 
#!/bin/bash

read a
echo "1st arg: $a"
read b
echo "2nd arg: $b"

(
echo "I'm starting"
sleep 10
echo "I'm done"
) &
disown
実行例:
$ ./a.bash 
10
1st arg: 10
20
2nd arg: 20
I'm starting
$
確認する:
$ ps -eaf|grep a.bash
saml      6774     1  0 01:02 pts/1    00:00:00 /bin/bash ./a.bash
saml      6780 10650  0 01:02 pts/1    00:00:00 grep --color=auto a.bash
10秒後:
$ I'm done

おすすめ記事