0

How to run autopostgresqlbackup in a cron job?

I setup a new cronjob this way:

34 20 * * * echo "DAILY INTERNAL BACKUP - POSTGRESQL" && sudo autopostgresqlbackup

Unfortunately this isn't working. Here is the message I received in my mailbox.

DAILY INTERNAL BACKUP - POSTGRESQL 
/bin/bash: autopostgresqlbackup: command not found

The autopostgresqlbackup is installed and working well in my server.

I want to control when backups are done through my own cron jobs, is it possible?

  • Please add the absolute path to autopostgresqlbackup – George Udosen Sep 27 '17 at 18:57
  • And this echo "DAILY INTERNAL BACKUP - POSTGRESQL" will not work rather put that into a file with >> – George Udosen Sep 27 '17 at 23:36
0

Now your cron job won't work as is:

34 20 * * * echo "DAILY INTERNAL BACKUP - POSTGRESQL" && sudo autopostgresqlbackup

Several things there:

  1. This echo "DAILY INTERNAL BACKUP - POSTGRESQL" won't be seen as cron runs in it's own shell

  2. This sudo autopostgresqlbackup:

    • sudo isn't needed to run cron job, since I assume your root
    • autopostgresqlbackup, the full path to this command is needed to get it to run.

So your cron job might look like this:

34 20 * * * echo "DAILY INTERNAL BACKUP - POSTGRESQL" >> /var/log/postlog && /path/to/binary/autopostgresqlbackup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.