문제

I run a script which ssh a host and runs a java program. I use nohup and want the output and error log file name to be as hostnameoutput.log and hostnameerror.log. I can't get to run the program. I tried to save the value in a variable and append it to the log file name and tried the direct approach also.

The one below is the direct approach to create a log file which appends the machine name. What is the error here?

ssh $host "hostname; nohup java -cp program.jar >hostnameoutput.log 2>hostnameerror.log & "
도움이 되었습니까?

해결책

Where do you want the log file - assuming /bin/bash

creates remote logfile with remote host name:

ssh $host 'nohup java -cp program.jar >`hostname`output.log 2>`hostname`error.log &'

creates local logfile with remote host name

 nohup (ssh $host 'java -cp program.jar ' > ${host}.output.log 2> ${host}error.log ) &

I cannot honestly tell what you want, please use this a starting point.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top