web_logs: Use mktemp for tmpfile
This commit is contained in:
parent
1fdb448fc4
commit
5ec0221634
1 changed files with 8 additions and 7 deletions
|
@ -24,15 +24,16 @@ get_vhosts | while read -r vhost ; do
|
|||
[ -d "$destdir" ] || mkdir "$destdir"
|
||||
for i in $(seq 0 7); do
|
||||
isodate="$(print_date $i)"
|
||||
outfile="${destdir}/access.log.${isodate}"
|
||||
tmpfile="$(mktemp -p "$destdir")"
|
||||
trap 'rm -f "$tmpfile"' EXIT
|
||||
combine-logs -d "$isodate" \
|
||||
/srv/weblog/*/"${vhost}".access.log* > "${outfile}.tmp"
|
||||
if [ -s "${outfile}.tmp" ]; then
|
||||
mv "${outfile}.tmp" "$outfile"
|
||||
xz -6 "$outfile"
|
||||
else
|
||||
rm -f "${outfile}.tmp"
|
||||
/srv/weblog/*/"${vhost}".access.log* | xz -6 > "$tmpfile"
|
||||
if [ "$(xzcat "$tmpfile" | cut -c 1)" = "" ]; then
|
||||
rm -f "$tmpfile"
|
||||
break
|
||||
else
|
||||
chmod 0640 "$tmpfile"
|
||||
mv "$tmpfile" "${destdir}/access.log.${isodate}.xz"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue