10

nohup: redirecting stderr to stdout解决办法

 3 years ago
source link: https://blog.csdn.net/iechenyb/article/details/76270595
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

nohup: redirecting stderr to stdout解决办法

original.png
iechenyb_ newCurrentTime2.png 于 2017-07-28 17:20:01 发布 articleReadEyes2.png 1460
分类专栏: 环境搭建 文章标签: nohup
在生产环境下启动Weblogic时,发现原来好好的nohup信息输出到指定文件中的功能,突然出问题了。现象是控制台输出的信息一部分输出到了我指定的文件,另一部分却输出到了nohup.out,而我是不想让它产生nohup.out文件,不知道是什么原因。

我的启动命令是这样的:
nohup bin/startManagedServer.sh myserver htp://192.168.0.1 -Xms2048m -Xmx2048m > logs/myserver.out & 现在指行这个命令,会给我产生两个文件,一个中logs/myserver.out,另一个是nohup.out文件。
怎样才能让它不产生nohup.out文件呢。
网上搜了半天,据说好象可以把后面的 “ & ” 改成 “ 2>&1 & ”,于是把启动命令改成如下:

nohup bin/startManagedServer.sh myserver htp://192.168.0.1 -Xms2048m -Xmx2048m > logs/myserver.out 2>&1 &再次执行,问题解决。

解释如下:

2>
表示把标准错误(stderr)重定向,标准输出(stdout)是1。

尖括号后面可以跟文件名,或者是&1, &2,分别表示重定向到标准输出和标准错误。

2> &1
1> &2
2> stderr.log
1> stdout.log


Recommend

  • 34
    • 微信 mp.weixin.qq.com 5 years ago
    • Cache

    nohup VS screen

    说到在Linux系统上后台运行任务,可能很多人的第一反应是 nohup 命令,可能还会有人提到 screen 命令。今天老张就给大家介绍这两个命...

  • 15
    • blog.mathieu-leplatre.info 4 years ago
    • Cache

    Python UTF-8 print fails when redirecting stdout

    Python UTF-8 print fails when redirecting stdoutPython UTF-8 print fails when redirecting stdout Wed 26 January 2011Consider the following piece of code: # -*- coding: utf-8 -*- print u"Վարդանաշեն" Runni...

  • 19
    • drewdevault.com 4 years ago
    • Cache

    Redirecting stderr of a running process

    Redirecting stderr of a running process Redirecting stderr of a running process May 4, 2018 on Drew DeVault's blog During the KDE sprint in Berlin,

  • 30
    • www.devdungeon.com 4 years ago
    • Cache

    Using stdin, stdout, and stderr in Python

    Introduction Among the popular operating systems, they have all standardized on using standard input, standard output, and standard error with file desciptors 0, 1, and 2 respectively. This allows you to pipe the inputs and outputs...

  • 20

    Introduction When you use print() in python the output goes to standard output or sys.stdout. You can directly call sys.stdout.write() instead of using print(), but you can also co...

  • 28
    • www.devdungeon.com 4 years ago
    • Cache

    STDIN, STDOUT, STDERR, Piping, and Redirecting

    Introduction Operating systems recognize a couple special file descriptor IDs: STDIN - 0 - Input usally coming in from keyboard. STDOUT - 1 - Output from the...

  • 17
    • note.qidong.name 4 years ago
    • Cache

    Bash打印中的stdout与stderr

    Bash打印中的stdout与stderr 2017-07-26 10:58:36 +08  字数:2134  标签: Bash 简介stdout与stderr

  • 10

    将命令的输出重定向到文件或将其通过管道传递到另一个命令时,您可能会注意到错误消息已打印在屏幕上。在Bash和其他Linux Shell中,执行程序时,它使用三个标准I/O流。 每个流由一个数字文件描述符表示:0-stdin...

  • 12

    命令列工具的 stdout, stderr 輸出與 .NET 整合應用-黑暗執行緒 昨天提到的 Linux 掃描工具 - scanimage,剛好有個經典輸出分流行為,scanimage 將圖檔傳到標準輸出(Standard Output),...

  • 9

    Conversation Contributor In all other places (e.g. bootstrap.py, opt-dis...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK