Search code examples
linuxshellnohup

nohup create new files nohup.out by day


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!


Solution

  • 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.