I'm trying to execute a remote postgresql script by command line (connecting to the server via putty) by using
\i myscript.sql
The problem comes when the script takes several hours to complete and VPN connection to the server (and consequently putty session) close. I can't really control that part because it's a local security policy. The session closing makes the execution of the script to cancel.
Is there an easy way to let the script run in the server regardless I'm still connected to it?
After you putty in use GNU screen
or one of its equivalents like tmux
before you run psql. This will preserve your session when you get disconnected so you just reconnect to it next time you log in.