Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose with crontab

I recently have a problem when I want to execute docker-compose command in crontab.

I have a docker-compose YAML file that defined all the services I need, say “docker-compose.yml". And I also have a Makefile in which I had written some command to do something.

My makefile is:

.PHONY operate
operate:
    /usr/local/bin/docker-compose -p /project -f ~/docker-compose-production.yml run rails env

This make script worked fine when it executed in shell. It listed all the environment var I defined in docker-compose.yml. But when I putted it in crontab. The result became strange, it listed nothing but only the $PATH.

My crontab file is:

57 21 * * * make -f ~/Makefile operate  >~/temp 2>&1

I guess there must be some environment var that docker-compose must have but I don’t know. Do you have any idea about this problem?

like image 663
user3743457 Avatar asked Jun 18 '15 02:06

user3743457


1 Answers

you can use

10 3 * * 0 /usr/local/bin/docker-compose -f /www/ilanni.com/docker-compose.yml start > /dev/null
like image 195
lanni654321 Avatar answered Nov 01 '22 21:11

lanni654321