Could not find a "psql" to execute
For further context, the bash script is executed from a shell_exec in a php page (fastcgi/nginx).

Try hard setting the path to the psql script so you don't rely on the environmental PATH and PHP setting that when it calls the shell,
Rather than,
$output = shell_exec('psql ...');

Try (or wherever command -v psql shows it's located)
$output = shell_exec('/usr/bin/psql ...');