cron job to start docker process and stop docker process
docker run --name my-mongo -d mongo
Now I wish I could start this same docker process (same ID) everyday at 6am and stop it everyday at 6pm. Here is what I did in the cron:
crontab -e 0 18 * * * /usr/bin/docker stop my-mongo 0 6 * * * /usr/bin/docker start my-mongo
But it didn’t run as expected, how to make it works?
I wish not to runt the
mongo daemon with cron inside the docker container cause it is very complicated process.
I am using root account and this is CentOS linux.
It turns out my
crond service is not running, after run
service crond start and everything works.