Score:0

Execution command is not working correctly

bo flag

I have this command in the crontab

 bash /opt/database/pg_backup_rotated.sh -c /opt/database/pg_backup.config >> /opt/data/logs/daily-database_dump.log 2>&1

and in the.bashrc I have PG_PASSWORD supplied for the backup user. The crontab stops by asking password while executing the above command through the terminal and works fine (it does not ask for a password). What is wrong?

I am using instructions from there to backup: https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux

hr flag
cron executes bash *non-interactively*, which bypasses your `PG_PASSWORD` assignment in ~/.bashrc
Manap Shymyr avatar
bo flag
@steeldriver thx for the response. How can I fix it?
Score:1
pl flag

If you're using pg_dump in your backup script, it can read from ~/.pgpass in the home directory of the calling user. So create a ~/.pgpass file with the password in it.

hostname:port:database:username:password

For example:

localhost:5432:application_production:application:OukaaKu9oleif4Oomee2Gubaw9shie7h

Here's the documentation about that file.

Manap Shymyr avatar
bo flag
Thanks for your response. However, I am not using pg_dump. I have added the link for my method
pl flag
Those scripts appear to call `pg_dump`?
Manap Shymyr avatar
bo flag
yeap. okay i will try
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.