上記のような感じです
TIME=1
sudo su - postgres -c "psql -d データベース名 -c 'select time from テーブル
名 where current_timestamp + "-$TIME months" < time;'"
実行したのはこれです