Arifur Rahim
Arifur Rahim

Reputation: 83

Run docker command in bash file and run using crontab

#!/bin/bash

docker exec -ti erpnext sh -c "cd /home/frappe/frappe-bench/ &&
/usr/local/bin/bench backup"

echo 'Hello, world.' >foo.txt

The above code is my bash file. Here have two command

  1. create txt file
  2. execute docker container

If I run this command

cd /home/arifur/workspace_python/erpdatabasebackup && bash backup_database.sh

in terminal then it is working

But when I run in crontab

* * * * * cd /home/arifur/workspace_python/erpdatabasebackup && bash backup_database.sh

then only txt file creation is working but docker container is not working.

Upvotes: 1

Views: 1506

Answers (1)

logan rakai
logan rakai

Reputation: 2557

The -ti requests to use a pseudo-tty and run in interactive mode but cron does not attach to any TTY. Try removing -ti as in

docker exec erpnext sh -c "cd /home/frappe/frappe-bench/ && /usr/local/bin/bench backup"

Upvotes: 5

Related Questions