linux - nohup - 不打印所有日志

标签 linux unix nohup

我正在运行两个脚本

# Script 1
nohup sh {command} &

并且 nohup.out 包含所有日志的详细信息(对于脚本 1)

# Script 2 
nohup sh {command} > {log_path} 2>&1 &

但是 nohup.out 只有下面列出的有限日志(对于脚本 2),

## Script2 output
   Shutdown message has been posted to the server.
   Server shutdown may take a while - check logfiles for completion 

如何在 nohup.out 本身中使用脚本 2 格式生成所有日志。

最佳答案

如果你想同时拥有这两个文件(nohup.out 和 {log_path}),你可以尝试:

((nohup {command}) > >(tee {log_path}) 2> >(tee {log_path}))>> nohup.out 

命令行第一部分解释here .

在此之后,您只需将输出重定向(附加)到 nohup.out

关于linux - nohup - 不打印所有日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44653961/

相关文章:

linux - 使用打开进程的时间保存变量

c - 与之前 fork 的子进程共享一个套接字

linux - 为什么 tcpdump 不在后台运行?

linux - "chown nginx:nginx * -R"有什么作用?

linux - 召唤其他脚本的菜单

linux - POSIX 中的 S_IRUSR 语义

perl - 如何使用 Cygwin 在 perl 脚本中运行系统命令

macos - OS X 终端中的 Bash 提示损坏

python - 使用 nohup (LINUX) 访问后台工作的进度 - 获取前台

linux - 使用 crontab & nohup 将输出重定向到具有日期格式名称的文件