Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass crontab command when running docker

Tags:

docker

I want to run docker by docker run command and want to pass crontab command like bleow.

crontab -l | '{ /bin/cat; /bin/echo "*/5 * * * * <some command>"; }' | crontab -

The above command will create a cronscript which will run every 5 mins inside the new created docker container.

I dont need to supply this command when building image. *This docker will be created when job is scheduled.

like image 877
Hikmat Avatar asked Jan 06 '18 13:01

Hikmat


1 Answers

docker run -it image /bin/bash -c "crontab -l | /bin/cat; /bin/echo \"*/5 * * * * <some command>\" |crontab - ; service cron restart"
like image 68
Ravi Avatar answered Nov 08 '22 11:11

Ravi