linux - nohup 每天创建新文件 nohup.out

标签 linux shell nohup

我不知道我是否可以用 nohup 做到这一点,但这是个问题....我有这个命令:

nohup java -XX:MaxHeapFreeRatio=70 -Xmx2048M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof -jar $iscsiJar &

我希望当日期改变时,我保存前一天的 nohupYYYYMM01.out 并创建另一个文件 nohupYYYYMM02.out ,当然,不终止我的进程。 =)

有可能吗,如何在 shell 脚本中编程?

非常感谢!

最佳答案

我认为一个解决方案是使用 Supervisord .

下面以/etc/supervisord.conf为例

...
[program:coherence]
command=java -XX:MaxHeapFreeRatio=70 -Xmx2048M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof -jar $iscsiJar &
directory=/u01/jdk
autostart=true
autorestart=true
startretries=3
stderr_logfile=/var/log/java.err.log
stdout_logfile=/var/log/java.out.log
user=oracle
stopsignal=KILL
killasgroup=true
stopasgroup=true

使用 supervisord,您可以像服务一样停止/启动此进程

关于linux - nohup 每天创建新文件 nohup.out,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27449372/

相关文章:

c - Execv Linux printf 不起作用

html - 我的 HTML 页面如何在客户端访问 socket.io?

linux - 自定义命令创建

php - 在 Linux 上将 php 文件放在后台

c - 如何在 C 中设置运行时字符集?

linux - 从任何目录运行脚本

linux - BASH:自动完成 printf "%s"的 $keyword

bash - 用法 : command not found

linux - nohup - 不打印所有日志

linux - 在 nohup 上运行的服务消耗大量内存