viernes, 18 de febrero de 2011

Procesando archivos en pararelo en bash con "xargs"

function process_file {
file=$1
do_something_with $file
}
export -f process_file


find PATH -type f | xargs --max-args=1 --max-procs=NUM -I{} bash -c process_file \{\}
or a shorter version
find PATH -type f | xargs -n1 -PNUM -I{} bash -c process_file \{\}



Where NUM is the number of parallel jobs and PATH where to start looking for the files.


source

jueves, 10 de febrero de 2011

creando una postgres db en ramdisk

#ramdisk de 5GB
mount -o size=5G -t tmpfs tmpfs /mnt/ramdb
chown -R postgres.postgres /mnt/ramdb

#en postgres ahora
CREATE TABLESPACE ramdb LOCATION '/mnt/ramdb';
CREATE DATABASE db WITH TABLESPACE ramdb;