Skip to content

Instantly share code, notes, and snippets.

View waltercool's full-sized avatar

WalterCool waltercool

View GitHub Profile
@waltercool
waltercool / postgres_queries_and_commands.sql
Created June 9, 2017 16:28 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
  1. Stopping a zombie machine: aws opsworks stop-instance --instance-id <opsworks ID>

  2. Resize root disk on AWS:
    z) partprobe /dev/xvdX
    a) parted /dev/xvdX print
    b) parted /dev/xvdX resizepart Y && resize2fs /dev/xvdXY # resize2fs needed to update the partition table

Update for xfs partitions:

a) growpart /dev/xvda 1