To get a list of running SQL queries, log into the PostgreSQL CLI:
psql -U username database
Replace username and database with the proper values. Then run this query:
SELECT procpid,datname,usename,client_addr,waiting,query_start,current_query FROM pg_stat_activity;
Inside the list is also the procpid, which you will need to kill a running query. To kill, run this query, substituting with the proper procpid:
SELECT pg_cancel_backend(procpid);
To have scripted automated backup of PostgreSQL databases on a linux platform, you can create a script like so:
#!/bin/bash PGPASSWORD="your-password" /usr/bin/pg_dump -U user database > sql-file.sql
Replace user and your-password with your username and password; replace database with the database you want to backup. The output of the dump goes to stdout and can be piped to a plain text file or compressed to something else.
« ‹ | November 2024 | › » | ||||
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |