I have created a DB called 'enws'. I'm using a python script 'db_store.py' for populating the DB from data stored at a file called 'xSparse.txt'. I'm very new to linux and postgresql and I'd like to know whether the population script, called from remote terminal (ssh), dies if I cancel such a terminal from which I have called it? See below my setting:
python db_store.py -cs --file xSparse.txt --dbname enws
enws [local] INSERT
enws [local] CREATE TABLE waiting
db_store.py -cs --file xSparse.txt --dbname enws
Use a screen for scripts which take a long time to run.
sudo apt-get install screen
Some screen useful commands:
screen -S foo //create a new screen called foo screen -ls //List all your screens screen -r foo //resume your foo screen
To exit a screen press ctrl+A and then D To when you are inside a screen, if you type "exit", it will exit your current screen. So, login with ssh, type something like:
screen -S script python db_store.py -cs --file xSparse.txt --dbname enws ctrl+a ...d
And screen -r script to reopen it.
It allows you to run whatever you want, and it will keep running even closing the terminal.
If your script is sending a query to a database and you exit the script, the database will perform the query anyway, because once the script sends the query to the database, the only way to stop it is killing it from sql or shutting down the database service (or turning off the computer)