No nohup logs on remote server












1















I'm trying to start a proccess on remote server with ssh.
I need to log stdout on target server (not the local one)



Here is the script:



sshpass -p mypwd ssh root@myserver.com nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &


Process starts fine, but logs are created on local server. Checked with



find . -name 'log.log'


I tried to wrap nohup command to double quotes



sshpass -p mypwd ssh root@myserver.com "nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &"


Process starts fine, but no logs are present on both servers.



How can I make nohup send stdout to log file on remote server?










share|improve this question







New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The last command should at least have created log.log file on the server, or have failed if creating the file was impossible. Are you sure you know the directory where the command run? Did you look in the right directory? What if you redirected to a file with absolute path?

    – Kamil Maciorowski
    Jan 14 at 12:47











  • @Kamil Maciorowski, I've scanned entire server (from root) & checked manually the home folder and folder with jar. No file

    – Ermintar
    Jan 14 at 12:50
















1















I'm trying to start a proccess on remote server with ssh.
I need to log stdout on target server (not the local one)



Here is the script:



sshpass -p mypwd ssh root@myserver.com nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &


Process starts fine, but logs are created on local server. Checked with



find . -name 'log.log'


I tried to wrap nohup command to double quotes



sshpass -p mypwd ssh root@myserver.com "nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &"


Process starts fine, but no logs are present on both servers.



How can I make nohup send stdout to log file on remote server?










share|improve this question







New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • The last command should at least have created log.log file on the server, or have failed if creating the file was impossible. Are you sure you know the directory where the command run? Did you look in the right directory? What if you redirected to a file with absolute path?

    – Kamil Maciorowski
    Jan 14 at 12:47











  • @Kamil Maciorowski, I've scanned entire server (from root) & checked manually the home folder and folder with jar. No file

    – Ermintar
    Jan 14 at 12:50














1












1








1








I'm trying to start a proccess on remote server with ssh.
I need to log stdout on target server (not the local one)



Here is the script:



sshpass -p mypwd ssh root@myserver.com nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &


Process starts fine, but logs are created on local server. Checked with



find . -name 'log.log'


I tried to wrap nohup command to double quotes



sshpass -p mypwd ssh root@myserver.com "nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &"


Process starts fine, but no logs are present on both servers.



How can I make nohup send stdout to log file on remote server?










share|improve this question







New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm trying to start a proccess on remote server with ssh.
I need to log stdout on target server (not the local one)



Here is the script:



sshpass -p mypwd ssh root@myserver.com nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &


Process starts fine, but logs are created on local server. Checked with



find . -name 'log.log'


I tried to wrap nohup command to double quotes



sshpass -p mypwd ssh root@myserver.com "nohup java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 &"


Process starts fine, but no logs are present on both servers.



How can I make nohup send stdout to log file on remote server?







bash ssh nohup






share|improve this question







New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Jan 14 at 12:32









ErmintarErmintar

1062




1062




New contributor




Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Ermintar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • The last command should at least have created log.log file on the server, or have failed if creating the file was impossible. Are you sure you know the directory where the command run? Did you look in the right directory? What if you redirected to a file with absolute path?

    – Kamil Maciorowski
    Jan 14 at 12:47











  • @Kamil Maciorowski, I've scanned entire server (from root) & checked manually the home folder and folder with jar. No file

    – Ermintar
    Jan 14 at 12:50



















  • The last command should at least have created log.log file on the server, or have failed if creating the file was impossible. Are you sure you know the directory where the command run? Did you look in the right directory? What if you redirected to a file with absolute path?

    – Kamil Maciorowski
    Jan 14 at 12:47











  • @Kamil Maciorowski, I've scanned entire server (from root) & checked manually the home folder and folder with jar. No file

    – Ermintar
    Jan 14 at 12:50

















The last command should at least have created log.log file on the server, or have failed if creating the file was impossible. Are you sure you know the directory where the command run? Did you look in the right directory? What if you redirected to a file with absolute path?

– Kamil Maciorowski
Jan 14 at 12:47





The last command should at least have created log.log file on the server, or have failed if creating the file was impossible. Are you sure you know the directory where the command run? Did you look in the right directory? What if you redirected to a file with absolute path?

– Kamil Maciorowski
Jan 14 at 12:47













@Kamil Maciorowski, I've scanned entire server (from root) & checked manually the home folder and folder with jar. No file

– Ermintar
Jan 14 at 12:50





@Kamil Maciorowski, I've scanned entire server (from root) & checked manually the home folder and folder with jar. No file

– Ermintar
Jan 14 at 12:50










1 Answer
1






active

oldest

votes


















1














The point is that nohup must go before sshpass command to log all the output; every command with no nohup goes like this: nohup command or nohup command > output.log 2>&1






share|improve this answer








New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

    – Ermintar
    Jan 14 at 13:24











  • What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

    – Ermintar
    Jan 14 at 13:26











  • I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

    – Dasel
    Jan 14 at 13:32











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Ermintar is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494403%2fno-nohup-logs-on-remote-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The point is that nohup must go before sshpass command to log all the output; every command with no nohup goes like this: nohup command or nohup command > output.log 2>&1






share|improve this answer








New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

    – Ermintar
    Jan 14 at 13:24











  • What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

    – Ermintar
    Jan 14 at 13:26











  • I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

    – Dasel
    Jan 14 at 13:32
















1














The point is that nohup must go before sshpass command to log all the output; every command with no nohup goes like this: nohup command or nohup command > output.log 2>&1






share|improve this answer








New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

    – Ermintar
    Jan 14 at 13:24











  • What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

    – Ermintar
    Jan 14 at 13:26











  • I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

    – Dasel
    Jan 14 at 13:32














1












1








1







The point is that nohup must go before sshpass command to log all the output; every command with no nohup goes like this: nohup command or nohup command > output.log 2>&1






share|improve this answer








New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










The point is that nohup must go before sshpass command to log all the output; every command with no nohup goes like this: nohup command or nohup command > output.log 2>&1







share|improve this answer








New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Jan 14 at 12:36









DaselDasel

4497




4497




New contributor




Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Dasel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

    – Ermintar
    Jan 14 at 13:24











  • What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

    – Ermintar
    Jan 14 at 13:26











  • I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

    – Dasel
    Jan 14 at 13:32



















  • I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

    – Ermintar
    Jan 14 at 13:24











  • What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

    – Ermintar
    Jan 14 at 13:26











  • I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

    – Dasel
    Jan 14 at 13:32

















I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

– Ermintar
Jan 14 at 13:24





I tried to use nohup sshpass -p mypwd ssh root@myserver.com java -jar /tmp/jenkins/myjar.jar > log.log 2>&1 & the result was the same.

– Ermintar
Jan 14 at 13:24













What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

– Ermintar
Jan 14 at 13:26





What worked for me: sshpass -p mypwd ssh root@myserver.com "java -jar /tmp/jenkins/myjar.jar > log.log &" I'm wondering why

– Ermintar
Jan 14 at 13:26













I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

– Dasel
Jan 14 at 13:32





I should have worked to you; sometimes the redirection 2>&1 may cause interferences, if you type nohup shpass -p mypwd ssh root@myserver.com 'java -jar /tmp/jenkins/myjar.jar' > log.log it should redirect the output; the only point is that only the output would be redirected.

– Dasel
Jan 14 at 13:32










Ermintar is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Ermintar is a new contributor. Be nice, and check out our Code of Conduct.













Ermintar is a new contributor. Be nice, and check out our Code of Conduct.












Ermintar is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494403%2fno-nohup-logs-on-remote-server%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?