Starting Docker Containers With Cron

#docker #sysadmin

My backups run every hour unless there’s already another backup still running using the following in my user’s crontab:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 * * * * if ! [ `docker ps -qf "name=backups"` ] ; then docker start backups; fi