-1

I'm trying to create a Teleporter backup of my pihole Docker container by running a cronjob every night that calls a backup.sh script.

If I do this manually, it works fine by issuing the following command. It puts the teleporter info in the /backup folder I present in my docker container. This allows me to copy the file to a different file share:

docker exec -it -w /backup pihole sh -c "pihole -a -t"

If I run the same command by running it inside a bash script, it works fine as well.

However, when I call that bash script through a cron job, this particular command does not get executed. I can see this, because no pi-hole-0423585190c3-teleporter_.tar.gz file exists after the nightly run, and my logfile doesn't show this file either. All other backup jobs in the backup.sh script work fine.

Any thoughts ?

oguz ismail
  • 1
  • 16
  • 47
  • 69
  • Does this answer your question? [docker exec is not working in cron](https://stackoverflow.com/questions/37089033/docker-exec-is-not-working-in-cron) – James Risner Oct 23 '22 at 22:27

1 Answers1

0

Found the answer in an answer from another question.

Your docker exec command says it needs "pseudo terminal and runs in interactive mode" (-it flags) while cron doesn't attach to any TTYs.

Removed the "-it" and now is works

James Risner
  • 5,451
  • 11
  • 25
  • 47