Skip to content

Instantly share code, notes, and snippets.

@the-eric-kwok
Created June 2, 2018 05:29
Show Gist options
  • Select an option

  • Save the-eric-kwok/0e9555da386cba407d0fa4f1a5dffd0f to your computer and use it in GitHub Desktop.

Select an option

Save the-eric-kwok/0e9555da386cba407d0fa4f1a5dffd0f to your computer and use it in GitHub Desktop.
Split v2ray log and delete outdated logs.
#!/bin/bash
LOGPATH=/var/log/v2ray/
TIME=`date +"%Y%m%d %H:%M"`
MAXLOGDAY=20
cd $LOGPATH
# split logs
tar -zcf ${TIME}.log.tgz *.log
cat /dev/null > error.log
cat /dev/null > access.log
# delete outdated logs
find $LOGPATH -name "*.tgz" -type f -mtime +${MAXLOGDAY} -exec rm {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment