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?

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

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .