I wrote a script to REINDEX indexes in a database. Here is one of them: echo -e "\nreindex for unq_vbvdata_vehicle started at: `date "+%F %T"`" >> ${LOG_FILE} psql -U ${USERNAME} -h ${HOSTNAME} -d ${DBNAME} -c "REINDEX INDEX scm_main.unq_vbvdata_vehicle;" if [[ ${?} -eq 0 ]]; then echo "reindex for unq_vbvdata_vehicle finished at: `date "+%F %T"`" >> ${LOG_FILE} else echo "reindex for unq_vbvdata_
![How to use psql with no password prompt?](https://cdn-ak-scissors.b.st-hatena.com/image/square/2a53379c39df414b89526fa0b87c626122f0b7ef/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fdba%2FImg%2Fapple-touch-icon%402.png%3Fv%3D246e2cb2439c)