Skip to content

Instantly share code, notes, and snippets.

@karmatr0n
Last active August 29, 2015 14:08
Show Gist options
  • Save karmatr0n/156ea9b0f192a5182f8e to your computer and use it in GitHub Desktop.
Save karmatr0n/156ea9b0f192a5182f8e to your computer and use it in GitHub Desktop.
Simple script to delete files from records stored in a PostgreSQL database
#!/bin/sh
l=1000
psql_cmd="/usr/local/bin/psql"
while [ 1 ];
do
records=`$psql_cmd -U syslog_writer -d vigilante -t << EOF
DELETE FROM images_logs WHERE id IN (SELECT id FROM images_logs ORDER BY uploaded_at LIMIT $l);
EOF`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment