Linux: 运行 在子 shell 中

Linux: run in subshell

我想从脚本开始一个漫长的 运行ning 过程,然后退出,但我无处可去。这是我最简单的测试。每 运行,控制台将被阻塞 5 秒。

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

我 运行宁 Ubuntu 17.04 64, GNU bash,版本 4.4.7(1)-发布 (x86_64-pc-linux-gnu)

我是一个 Linux 菜鸟,我确定我什么都不懂。感谢任何帮助。

看起来你的脚本正在等待什么。将您的脚本粘贴到此处。

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

有几种方法可以做到这一点,我的首选方法是在行尾放置一个符号 &

通过this answer

找到更多方法

关于符号方法的更多解释here