I'm trying to run a jar file from a remote linux server using ssh The command goes like this
ssh -tt -i keyFile ubuntu@IP '
sudo chmod 777 /home/ubuntu/task.jar
sudo nohup java -jar /home/ubuntu/task.jar >> /home/ubuntu/nohup.out
'
But after running the terminal gets stuck at
nohup: ignoring input and appending output to 'nohup.out'
If I do a ctrl + C the jar stops running on the remote host
I tried adding & to the end of the command so it runs in the background like this
ssh -tt -i keyFile ubuntu@IP '
sudo chmod 777 /home/ubuntu/task.jar
sudo nohup java -jar /home/ubuntu/task.jar >> /home/ubuntu/nohup.out &
'
I get the terminal back but the jar doesn't run on the remote server at all. Am I doing something wrong?
disownnohup. Everything it does you can do yourself with only shell redirection anddisown, and usually you don't even needdisown.chmod 777is wrong and dangerous. You absolutely do not want to grant write access to executable or system files to all users under any circumstances. You will want to revert to sane permissions ASAP (for your use case, probablychmod 755) and learn about the Unix permissions model before you try to use it again. If this happened on a system with Internet access, check whether an intruder could have exploited this to escalate their privileges.