github.com/halybang/go-ethereum@v1.0.5-0.20180325041310-3b262bc1367c/networkScript/set_logrotate_env.sh (about)

     1  #!/bin/sh
     2  # set up the logrotate environment to backup wan-chain log data
     3  
     4  #   __        ___    _   _  ____ _           _       ____
     5  
     6  #   \ \      / / \  | \ | |/ ___| |__   __ _(_)_ __ |  _ \  _____   __
     7  
     8  #    \ \ /\ / / _ \ |  \| | |   | '_ \ / _` | | '_ \| | | |/ _ \ \ / /
     9  
    10  #     \ V  V / ___ \| |\  | |___| | | | (_| | | | | | |_| |  __/\ V /
    11  
    12  #      \_/\_/_/   \_\_| \_|\____|_| |_|\__,_|_|_| |_|____/ \___| \_/
    13  
    14  #
    15  
    16  #add wanchainlog logrotateconf 
    17  version="v1.0.1"
    18  if [ ! -n "$1" ];then
    19      echo "There is no version parameter input"
    20      tmp=`ls -lt $HOME/wanchain | grep '^d' | awk '{print $9}' | head -1`
    21      if [ -f "$HOME/wanchain/$tmp/bin/gwan" ];then
    22          version=$tmp
    23          echo "The newest version is $version"
    24      fi
    25  else
    26      echo "The input version parameter is $1"
    27      version=$1
    28  fi
    29  wanchainLogPath=$HOME/wanchain/$version/log/running.log
    30  wanchainLogRotateConf=/etc/logrotate.d/wanchainlog
    31  
    32  sudo touch $wanchainLogRotateConf
    33  sudo chmod 777 $wanchainLogRotateConf
    34  echo "
    35  $wanchainLogPath
    36  {
    37     su root list
    38     daily
    39     dateext
    40     rotate 31
    41     compress
    42     notifempty
    43     missingok
    44     copytruncate
    45  }
    46  " > $wanchainLogRotateConf
    47  sudo chmod 644 $wanchainLogRotateConf
    48  
    49  #add daily schedule to crontab
    50  sudo chmod 777 /etc/crontab
    51  sed -n '/cron.daily/p' /etc/crontab | sudo sed -i 's/25 6/59 23/g' /etc/crontab
    52  sudo chmod 644 /etc/crontab
    53  
    54  sudo /etc/init.d/cron restart