From 9bde61fa472fa6e48edef74bf3216ed194f47978 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Thu, 15 Jan 2026 12:22:44 +0100 Subject: [PATCH 1/4] Improved logging --- pdt.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pdt.sh b/pdt.sh index f486b14..c4d0788 100644 --- a/pdt.sh +++ b/pdt.sh @@ -8,8 +8,10 @@ do if [[ $output -gt 0 ]] then echo "ERROR! Exiting the program" + echo "Processed file: $file - $output" | tee -a "/var/log/pdt$(date +%d%m%Y).log" + echo "Log saved to /var/log/pdt$(date +%d%m%Y).log" exit 1 fi - echo "Processed file: $file: $output" | tee -a "/var/log/pdt$(date +%d%m%Y).log" + #echo "Processed file: $file: $output" | tee -a "/var/log/pdt$(date +%d%m%Y).log" done \ No newline at end of file From 51dfad5cb4069316ad01d92b29fe683c0ef357d6 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Thu, 15 Jan 2026 16:11:40 +0100 Subject: [PATCH 2/4] changed logging --- pdt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pdt.sh b/pdt.sh index c4d0788..48e88f1 100644 --- a/pdt.sh +++ b/pdt.sh @@ -8,10 +8,10 @@ do if [[ $output -gt 0 ]] then echo "ERROR! Exiting the program" - echo "Processed file: $file - $output" | tee -a "/var/log/pdt$(date +%d%m%Y).log" - echo "Log saved to /var/log/pdt$(date +%d%m%Y).log" + echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" + echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" exit 1 fi - #echo "Processed file: $file: $output" | tee -a "/var/log/pdt$(date +%d%m%Y).log" + echo "Processed file: $file - $output" done \ No newline at end of file From 435b1668eecc193d0635fa116b69f2c8bcdb6570 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Thu, 15 Jan 2026 16:24:17 +0100 Subject: [PATCH 3/4] Skipping processed files --- pdt.sh | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/pdt.sh b/pdt.sh index 48e88f1..1a8ffe7 100644 --- a/pdt.sh +++ b/pdt.sh @@ -1,17 +1,33 @@ #!/bin/bash +if [[ -f /var/www/html/storage/focode/processed_files.txt]] +then + readarray -t processed_files < /var/www/html/storage/focode/processed_files.txt +fi + readarray -t files < /var/www/html/storage/focode/file_list_temp.txt for file in "${files[@]}" do - output=$(php compress.php process "$file") - if [[ $output -gt 0 ]] - then - echo "ERROR! Exiting the program" - echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" - echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" - exit 1 - fi + for processed_file in "${processed_files[@]}" + do + if [[ "$file" == "$processed_file" ]] + then + echo "Skipping already processed file: $file" + continue + fi - echo "Processed file: $file - $output" + output=$(php compress.php process "$file") + echo "$processed_file" >> /var/www/html/storage/focode/processed_files.txt + + if [[ $output -gt 0 ]] + then + echo "ERROR! Exiting the program" + echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" + echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" + exit 1 + fi + + echo "Processed file: $file - $output" + done done \ No newline at end of file From 83045533ee3a385d7dd4ddd2ee905f84b551a1d2 Mon Sep 17 00:00:00 2001 From: Daniel Sosnowski Date: Fri, 16 Jan 2026 12:24:09 +0100 Subject: [PATCH 4/4] added control of the already processed files --- pdt.sh | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/pdt.sh b/pdt.sh index 1a8ffe7..b2a5795 100644 --- a/pdt.sh +++ b/pdt.sh @@ -1,33 +1,24 @@ #!/bin/bash -if [[ -f /var/www/html/storage/focode/processed_files.txt]] -then - readarray -t processed_files < /var/www/html/storage/focode/processed_files.txt -fi - readarray -t files < /var/www/html/storage/focode/file_list_temp.txt for file in "${files[@]}" do - for processed_file in "${processed_files[@]}" - do - if [[ "$file" == "$processed_file" ]] - then - echo "Skipping already processed file: $file" - continue - fi - output=$(php compress.php process "$file") - echo "$processed_file" >> /var/www/html/storage/focode/processed_files.txt + if [[ -f "/var/www/html/storage/focode/processed_files.txt" && $(grep -c "$file" "/var/www/html/storage/focode/processed_files.txt") -gt 0 ]] + then + echo "Skipping already processed file: $file" + continue + fi - if [[ $output -gt 0 ]] - then - echo "ERROR! Exiting the program" - echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" - echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" - exit 1 - fi + output=$(php compress.php process "$file") + if [[ $output -gt 0 ]] + then + echo "ERROR! Exiting the program" + echo "Processed file: $file - $output" | tee -a "/var/log/pdterr$(date +%d%m%Y).log" + echo "Log saved to /var/log/pdterr$(date +%d%m%Y).log" + exit 1 + fi - echo "Processed file: $file - $output" - done + echo "Processed file: $file - $output" | tee -a /var/www/html/storage/focode/processed_files.txt done \ No newline at end of file