Follow this procedure to use watch with a psql query from a Linux command prompt:
- Create a .pgpass file as follows:
- vi /root/.pgpass
- Fill in the file as follows:
- vi /root/.pgpass
*:*:<username>:<password>
- Execute the command:
chmod 0600 /root/.pgpass
- Execute the command:
watch 'psql -c "insert_query_here;" -U <username> <database_name>'