这如何在 sh(不是 bash!)中实现?
nohup sh -c 'helper-bcpy.sh "$0" "$1" "$2" "$3"' "$num" "$full_path" "$log" "$log_finished" >/dev/null &
Run Code Online (Sandbox Code Playgroud)
我原以为它会在后台发送进程(它确实如此)并将其与终端分离(它不会这样做——如果我从我启动脚本的地方关闭终端,helper-bcpy.sh
虽然看起来似乎不会完全执行)耗时的 wget 调用被正确执行......)。
我知道我可以使用,disown
但我需要在 sh 而不是 bash 中执行此操作...
#!/bin/sh
# $num $full_path $log $log_finished - computed before from parameters received by the script
nvram set led_disable=1
service restart_leds >/dev/null
nohup sh -c 'helper-bcpy.sh "$0" "$1" "$2" "$3"' "$num" "$full_path" "$log" "$log_finished" >/dev/null &
echo "copy process launched..."
exit 0
Run Code Online (Sandbox Code Playgroud)
helper-bcpy.sh
看起来像这样:
#!/bin/sh
wget -m -np -nH -nv --cut-dirs="$1" "$2" …
Run Code Online (Sandbox Code Playgroud)