Reputation: 17326
I'm running the following command (where variables have valid values for ssh command and $file - is a .sql file).
nohup ssh -qn ${ssh_user}@${dbs} "sqlplus $dbuser/${dbpswd}@${dbname} <<ENDSQL | tee "${sql_run_output_file}".ssh.log
set echo off
set echo on
set timing on
set time on
set serveroutput on size 1000000
@${file}
ENDSQL
"
When I was using the above command without "nohup" before ssh command, after 1 hour or so, my connection from source server (where im running ssh) was getting an error/message "Connection reset...." and hanging my BASH shell script (which contains this ssh command in it). When, I use nohup, i dont see the connection issue.
Here's what I'm trying to get and need your help.
Thanks.
Upvotes: 1
Views: 979
Reputation: 117457
You can still lose the connection when running ssh
under nohup
, so it's not really a good solution. If possible, I would recommend that you copy the sql file via scp
to the target server, then ssh
in to the server, open a screen
and run the command from there (Or run it under nohup
). Is that an option?
Upvotes: 1