run_log_clear.sh 971 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. if [ $# -lt 2 ]; then
  3. echo "Usage: run_log_clear.sh [start month before] [end month before]"
  4. echo " start month >= 6 at least"
  5. echo " end month > start month"
  6. echo "Sample: run_log_clear.sh 6 12 "
  7. echo " (Clear log before now 6 to 12 month)"
  8. exit 0;
  9. else
  10. if [ "$2" -lt "$1" ]
  11. then
  12. echo "Usage: run_log_clear.sh [start month before] [end month before]"
  13. echo " start month >= 6 at least"
  14. echo " end month > start month"
  15. exit 0
  16. fi
  17. for idx in $(seq $1 $2)
  18. do
  19. now=$(( `date +%s`-(($idx*30)*86400)))
  20. target=`date -D '%s' +%Y.%m -d "$now"`
  21. echo $target
  22. `/bin/rm -f /Storage/SystemLog/[$target\]*`
  23. `/bin/rm -f /Storage/OCPP/[$target\]*`
  24. `/bin/rm -f /Storage/OCPP_PH/[$target\]*`
  25. done
  26. fi