K8S部署nginx切割日志

#  每天0点执行这个脚本,用于切割nginx日志
for pod in $(kubectl get pods -n service-a | grep gateway | awk '{print $1}'); do
  kubectl exec -ti -n service-a $pod -- /bin/mv /var/log/nginx/access.log /var/log/nginx/access_$(date +%F -d -1day).log
  kubectl exec -ti -n service-a $pod -- /usr/sbin/nginx -s reopen
done

 

posted @ 2021-11-24 15:15  缺个好听的昵称  阅读(87)  评论(0编辑  收藏  举报