Skip to content

Commit 9ed02a9

Browse files
Create Log_rotate.sh
1 parent 79d545f commit 9ed02a9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Log_rotate.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
f="/home/ec2-user/connections.data"
4+
5+
if [ ! -f $f ]
6+
then
7+
echo $f does not exist!
8+
exit
9+
fi
10+
11+
touch ${f}
12+
MAXSIZE=$((4096*1024))
13+
14+
size=`du -b ${f} | tr -s '\t' ' ' | cut -d' ' -f1`
15+
if [ ${size} -gt ${MAXSIZE} ]
16+
then
17+
echo Rotating!
18+
timestamp=`date +%s`
19+
mv ${f} ${f}.$timestamp
20+
touch ${f}
21+
fi

0 commit comments

Comments
 (0)