简体   繁体   中英

linux redirect java System.out to file

I running jar via "start-stop-daemon". My code:

PIDFILE=/var/run/$NAME.pid
USER=root
MAIN="/usr/share/folder/jarfile.jar"
DAEMON="/usr/bin/java"
ARGS="-server -Djava.awt.headless=true -jar $MAIN"

start() {
    start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$USER" --background --make-pidfile --startas "$DAEMON" -- $ARGS
}

stop() {
    start-stop-daemon --stop --quiet --pidfile $PIDFILE
    if [ -e $PIDFILE ]
        then rm $PIDFILE
    fi
}

I want redirect java System.out to file. When I try this code:

start() {
       start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$USER" --background --make-pidfile --startas /bin/bash -- -c "$DAEMON $ARGS  > /usr/share/folder/log.txt  2>&1"
}

method stop() does not stoped deamon.

How possibile to redirect System.out to log file?

Thanks!

您刚刚在第二部分中做了此操作,请检查/usr/share/folder/log.txt中的日志

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM