Pgpass
From PostgreSQL Wiki
Most access to the database, including the psql program, goes through the libpq library. This library includes a feature where if you specify a file called .pgpass you can put the password needed to connect as a user in there. This allows automating routine administration tasks through mechanisms like cron.
