From 1f02319909800f7c5f4e8ef46a68a8ca55ae60e2 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Thu, 4 Dec 2025 14:58:15 +0100 Subject: [PATCH] added and if instruction --- clearCache.sh | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/clearCache.sh b/clearCache.sh index e3df4f6..899d55d 100644 --- a/clearCache.sh +++ b/clearCache.sh @@ -1,5 +1,9 @@ #!/bin/bash +function loopDirs { + +} + declare -i diskUsage vhostDir="/var/www/vhosts" @@ -21,24 +25,27 @@ then do for path in "$subscription/httpdocs/shopsystem/application/cache/boxes"* "$subscription/httpdocs/shopsystem/appcation/cache/smarty_compiled" do - cd "$path" - echo -e "Czyszczę cache w subskrybcji $subscription...\n" - ls -1 > "/tmp/dirList.txt" - readarray -t dirList < /tmp/dirList.txt - for dir in "${dirList[@]}" - do - if [[ -d "$dir" ]] - then - echo -e "Czyszczenie $dir...\n" - cd "$dir" - ls -1 - cd .. - fi + + if [[ -d $path ]] + then + cd "$path" + echo -e "Czyszczę cache w subskrybcji $subscription...\n" + ls -1 > "/tmp/dirList.txt" + readarray -t dirList < /tmp/dirList.txt + for dir in "${dirList[@]}" + do + if [[ -d "$dir" ]] + then + echo -e "Czyszczenie $dir...\n" + cd "$dir" + ls -1 + cd .. + fi + done + fi + cd "$vhostDir" done - cd "$vhostDir" done - done - fi if [[ -f "/tmp/subscriptions.txt" ]] && [[ -f "/tmp/dirList.txt" ]]