nohup及命令输出到文件

1 篇文章 0 订阅

1指标准输出;2指错误输出,所以写成这样:command 1>output 2>error & ,正常的输出在output文件里,错误的输出在error文件里,command >output 2>error &

(1可以省略)

忽略错误输出:command 1>output 2>/dev/null & 

忽略标准输出:command 1>/dev/null 2>error &

忽略全部输出:command 1>/dev/null 2>/dev/null &

忽略全部输出:command >/dev/null 2>&1 &

错误输出和标准输出在一个文件:command 1>output 2>&1 &

错误输出和标准输出在一个文件:command 1>output 2>output & (X这种方式错误)

这样的文件输出,每次运行会覆盖现有的文件,如果我们希望追加而不是覆盖,那么就用>>符号,这样命令就是: command 1>>output 2>>error &

如果想退出窗口乃至退出登录仍然保持程序运行,再加上nohup,形如:nohup command 1>output 2>&1 &

nohup sh run.sh 1>run_info.log 2>run_error.log &

转:https://www.linuxidc.com/Linux/2016-09/135066.htm

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值