Skip to content

Instantly share code, notes, and snippets.

@simbalinux
Created July 13, 2018 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simbalinux/c7591e2c45c16353adba6d69baf9c1d7 to your computer and use it in GitHub Desktop.
Save simbalinux/c7591e2c45c16353adba6d69baf9c1d7 to your computer and use it in GitHub Desktop.
When logs cannot be truncated on a NAS and you need to pipe logs files and rotate forcefully
#!/bin/bash
## non ssl
exec >> "/var/www/vhosts/application/log/archive/test_ops/devel.domain.com_$(date +%Y-%m-%d).log";
while IFS= read -r line; do
if (( SECONDS > 10 )); then
exec >> "/var/www/vhosts/application/log/archive/test_ops/devel.domain.com_$(date +%Y-%m-%d).log"
SECONDS=0
fi
printf '%s\n' "$line";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment