nohup create new files nohup.out by day

2019-06-13 04:21发布

I don't know if I can do it with nohup, but this is the question.... I have this command:

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

and I want that when the day change I save the before day nohupYYYYMM01.out and create another file nohupYYYYMM02.out , of course, with out kill my process. =)

Is it possible, how do I program it in shell script?

thanks a lot!

1条回答
在下西门庆
2楼-- · 2019-06-13 04:42

I think one solution for this is using Supervisord.

Below a example of /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

Using supervisord you can stop/start this process like was a service.

查看更多
登录 后发表回答