Skip to content

Commit

Permalink
Merge pull request #2 from amdadulbari:main
Browse files Browse the repository at this point in the history
Main
  • Loading branch information
amdadulbari authored Dec 8, 2023
2 parents d3e7f44 + 649ddcc commit 112f76b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Bash Checks

on:
push:
branches-ignore: [ main ]
branches: [ main ]
pull_request:
branches: [ main ]

Expand All @@ -20,14 +20,15 @@ jobs:

- name: Check shell script formatting with shfmt
run: |
if ! shfmt -d *.sh; then
if ! shfmt -d */*.sh; then
echo "Shell script formatting issues detected."
exit 1
fi
- name: Run ShellCheck for syntax analysis
run: |
if ! find . -name "*.sh" -exec shellcheck {} +; then
if ! find . -name "*/*.sh" -exec shellcheck {} +; then
echo "Shell script syntax issues detected."
exit 1
fi
fi
5 changes: 2 additions & 3 deletions log-management/rotate-logs.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
# This Bash script automates the rotation and compression of log files in a specified directory, archiving them as tar.gz files.
#It also manages log retention by deleting archives older than a configurable number of days, defaulting to 7 days.

# If you are using this script, you can star this repo ;)
# If you are using this script, you can star this repo ;)

# Define the log directory and archive directory
LOG_DIR="/path/to/log/directory"
ARCHIVE_DIR="/path/to/archive/directory"

# Number of days to keep the log archives
DAYS_RETENTION=7

Expand All @@ -24,7 +23,7 @@ for log in "$LOG_DIR"/*.log; do
tar -czf "${ARCHIVE_DIR}/$(basename "$log" .log)_${CURRENT_DATE}.tar.gz" -C "$LOG_DIR" "$(basename "$log")"

# Clear the original log file
>"$log"
echo >"$log"
done

# Delete archives older than the specified number of days
Expand Down

0 comments on commit 112f76b

Please sign in to comment.