On Thu, 15 Jun 2000, Rick Petree wrote:
> When you sent a process to the background how do you turn off the
> annoying error messages that may come up.  For example: you use the find
> command to locate a file and you send this long process to the background
> and direct the output to a file that you will check later for the results.

  UNIX has the concept of two "output streams", called "standard out" and
"standard error".  Each has a file descriptor associated with it: 1 for
stdout, 2 for stderr.  If your shell is bash (or another Bourne-compatible
shell), you can redirect either of these two independently.

  cmd > cmd.out                 # execute cmd, stdout to cmd.out
  cmd 2> cmd.err                # execute cmd, stderr to cmd.err
  cmd > cmd.out 2> cmd.err      # stdout to cmd.out, stderr to cmd.err

So, to run a find command in the background, redirecting output to a file, and
simply discarding all error messages, use:

  find /some/dir > $HOME/find.out 2> /dev/null &

You may also be interested in the "nohup" command, which prevents commands
from terminating if the terminal "hangs up" on it (or log out or close the
xterm or whatever).  For example:

  nohup find /some/dir > $HOME/find.out 2> /dev/null &

> 2. When using the nice command to change the priority of a process how
> does it work if the process is already running?

  The nice command, per se, cannot do that.

  There is a command "renice" that can change the priority of a running
process.  For example:

  renice 20 1234

will take process 1234, and change its priority so that it only runs when the
system is otherwise idle.

  Note that, for security and historical reasons, only root can increase the
priority of a running job.

-- 
Ben Scott <[EMAIL PROTECTED]>
Net Technologies, Inc. <http://www.ntisys.com>
Voice: (800)905-3049 x18   Fax: (978)499-7839


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to