crontab does not work, but I do not see any trouble with this

Asked by Orgil Dashzeveg

Hello.
I have inserted a few entries to the crontab using "sudo crontab -e" and vim editor. My crontab looks like below:
---------------------------------------------------------------
# m h dom mon dow command
5 11 * * * /home/gaali/db_backup.sh
~
~
~
--------------------------------------------------------------

db_backup.sh looks like below:
--------------------------------------------------------------
dest="$HOME"
day=$(date '+%y%m%d_%H%M')
name="gaali"
archive_file="$day.tar"

echo "Backing $name > $dest/$name$archive_file up ..."

pg_dump -U postgres -Ft -b $name > $dest/$name$archive_file

echo "... Backup finished"
-------------------------------------------------------------

When I run "sudo /home/gaali/db_backup.sh" then it works fine. But it requires postgreSQL password.

Does my shell command requiring password cause the crontab failure?

Please help me!!!
Any suggestion would be highly appreciated!

... Orgil

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu cron Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

Quite likely. I suggest you see if the command can be fed the paasword. Possibly make a textfile with the password in and use

Command options < /path/to/passwordfile

Add the

< /path/to/passwordfile

Bit but change the path to the actual path. I suggest you post on some sql forums too as it's more specific to your issue.

Can you help with this problem?

Provide an answer of your own, or ask Orgil Dashzeveg for more information if necessary.

To post a message you must log in.