Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to backup a huge number of records and delete them, but I don't have complete access to database server so I can't run my script on the server. because it takes so long I need to submit jobs(say REINDEX for example) and then turn off my computer. Is it possible to do something like this?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Not really - there is pgAgent - part of pgAdmin package, that could be abused to do it, but it's not its main purpose.

Generally, to run such long queries/jobs, you need somewhere to have psql session to live until it will finish. Usually, psql on screen on some kind of server - database server, or app server, doesn't matter much.

share|improve this answer
add comment

If your server runs on Linux you can start a psql job and send it to the background, then it runs regardless of the client interface. Something like this:

psql mydb -c 'REINDEX TABLE huge_table' > ~/reinedex.log &

Note the & at the end of the command line. You can do the same interactively by pressing [ctrl][z]. Have a look at the fg command, too: man fg.

The example redirects the output of the command to a log file in the home directory of the user: > ~/reinedex.log

Works with as many jobs in parallel as you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.