Skip to content

Instantly share code, notes, and snippets.

@prhomhyse
Created July 25, 2021 23:25
Show Gist options
  • Save prhomhyse/0ecf96820003aecd6484ed28d9b963a5 to your computer and use it in GitHub Desktop.
Save prhomhyse/0ecf96820003aecd6484ed28d9b963a5 to your computer and use it in GitHub Desktop.

Revisions

  1. prhomhyse created this gist Jul 25, 2021.
    16 changes: 16 additions & 0 deletions clear-nginx-cache.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/bin/bash

    LOG="/var/log/cache-clean.log"

    #Check if the /run directory size is above 100MB

    run_size=`du -sh /run | awk '{print $1}' | grep -Eo '[0-9]{3}'`

    if [[ $run_size -gt 100 ]]; then

    rm -rf /run/nginx-cache/*

    #Add timestamp to the log
    echo "$(date +'%F %T')" >> $LOG

    fi