2017-06-09 45 views
1

我想从一个脚本启动一个长时间运行的进程,然后退出,但我无处可去。这是我最简单的测试。每次运行时,控制台都会被阻塞5秒钟。Linux:在子shell中运行

// Create script 
[email protected]:~/workspace/bin$ cat > test.sh 
sleep 5 
// Verify script 
[email protected]:~/workspace/bin$ cat test.sh 
sleep 5 
// Make executable 
[email protected]:~/workspace/bin$ chmod 777 test.sh 
// Expect to wait 
[email protected]:~/workspace/bin$ ./test.sh 
// Expect to return, still waits 
[email protected]:~/workspace/bin$ ./test.sh ? 
// Ditto 
[email protected]:~/workspace/bin$ nohup ./test.sh ? 
nohup: ignoring input and appending output to 'nohup.out' 
[email protected]:~/workspace/bin$ 

我运行Ubuntu 17.04 64, GNU的bash,版本4.4.7(1)-release下(x86_64-PC-Linux的GNU)

我是一个Linux小白,我我确定我没有得到什么。任何帮助表示赞赏。

回答

1

使用符号:nohup ./test.sh &

+0

是的。它有助于使用正确的字符。真的,谢谢你指出。 Steve11235

0

看起来像你的脚本正在等待的东西。将你的脚本粘贴在这里。

+0

是如何从'chomd'不同,那么在原来的问题执行,以及这将如何把'test.sh'在后台? –

0

有几个方法可以做到这一点,我去到的方法是把一个符号&在该行的末尾。

更多的方式被发现的符号方法this answer

更多解释here