使用nohup在背景中執行程式

通常使用putty進行ssh連線時,常常遇到要長時間的執行一個指令
而半徒若將putty關閉的話,這個程式也將會被終止.
因此必須將程式放置到背景中執行

方法1: 執行結果輸出至nohup.out

nohup command &

方法2: 指定輸出logfile

nohup command > logfile &

方法3: 不要輸出任何資訊

nohup command >/dev/null 2>&1 &

若要搭配sudo的話,其用法如下

sudo sh -c 'nohup command &'