Reputation: 389
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 & "
Upvotes: 1
Views: 8688
Reputation: 16379
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.
Upvotes: 2