我用nohup命令有问题。
当我运行我的工作时,我有很多数据。输出nohup。Out变得太大,我的进程变慢了。我如何运行这个命令而不得到noup .out?
我用nohup命令有问题。
当我运行我的工作时,我有很多数据。输出nohup。Out变得太大,我的进程变慢了。我如何运行这个命令而不得到noup .out?
当前回答
sudo bash -c "nohup /opt/viptel/viptel_bin/log.sh $* &> /dev/null" &
重定向sudo的输出会导致sudo重新询问密码,因此需要一种笨拙的机制来执行这种变体。
其他回答
你可能需要使用分离程序。您可以像nohup一样使用它,但是它不会产生输出日志,除非您要求它这样做。下面是手册页:
NAME
detach - run a command after detaching from the terminal
SYNOPSIS
detach [options] [--] command [args]
Forks a new process, detaches is from the terminal, and executes com‐
mand with the specified arguments.
OPTIONS
detach recognizes a couple of options, which are discussed below. The
special option -- is used to signal that the rest of the arguments are
the command and args to be passed to it.
-e file
Connect file to the standard error of the command.
-f Run in the foreground (do not fork).
-i file
Connect file to the standard input of the command.
-o file
Connect file to the standard output of the command.
-p file
Write the pid of the detached process to file.
EXAMPLE
detach xterm
Start an xterm that will not be closed when the current shell exits.
AUTHOR
detach was written by Robbert Haarman. See http://inglorion.net/ for
contact information.
注意,我与该程序的作者没有任何关系。我只是一个满意的程序用户。
nohup some_command > /dev/null 2>&1&
这就是你所需要做的!
您可以执行如下命令。
nohup <your command> & > <outputfile> 2>&1 &
如。 我在脚本里面有一个nohup命令
./Runjob.sh > sparkConcuurent.out 2>&1
sudo bash -c "nohup /opt/viptel/viptel_bin/log.sh $* &> /dev/null" &
重定向sudo的输出会导致sudo重新询问密码,因此需要一种笨拙的机制来执行这种变体。
你试过重定向所有三个I/O流吗:
nohup ./yourprogram > foo.out 2> foo.err < /dev/null &