If you run the script as OS user postgres
it should not request a password in a standard setup, because password-less peer
access (or ident
on older versions) is enabled in pg_hba.conf
for the postgres user.
So make it a cronjob of postgres if you can. Or enable password-less access for the OS user running the job.