标签:star ted status roo success led gre res rest
vim restart.sh
#!/bin/bash # set container ID ID=4402f2ddc9dd # check container running status docker ps -a |grep -i exited 2>&1 >/dev/null # restart container if [ $? -eq 0 ];then docker restart $ID 2>&1 >/dev/null if [ $? -eq 0 ];then echo -e "\033[32m The Container ID=$ID restart successfully ! \033[0m" else echo -e "\033[31m The Container ID=$ID restart Failed !!!\033[0m" fi else echo -e "\033[31m The Container ID=$ID is Running, No need to restart !\033[0m" fi
crontab -u root -e
5 * * * * sh /data/nginx/restart.sh
标签:star ted status roo success led gre res rest
原文地址:https://www.cnblogs.com/petersonx/p/12039104.html