()
| 472 | |
| 473 | # 清理php_session文件 |
| 474 | def ClearSession(): |
| 475 | spath = '/tmp' |
| 476 | total = count = 0 |
| 477 | import shutil |
| 478 | print('|-正在清理PHP_SESSION ...') |
| 479 | for d in os.listdir(spath): |
| 480 | if d.find('sess_') == -1: continue |
| 481 | filename = spath + '/' + d |
| 482 | fsize = os.path.getsize(filename) |
| 483 | print('|---[' + ToSize(fsize) + '] del ' + filename), |
| 484 | total += fsize |
| 485 | if os.path.isdir(filename): |
| 486 | shutil.rmtree(filename) |
| 487 | else: |
| 488 | os.remove(filename) |
| 489 | print('\t\033[1;32m[OK]\033[0m') |
| 490 | count += 1 |
| 491 | print('|-已完成php_session的清理,删除[' + str(count) + ']个文件,共释放磁盘空间[' + ToSize(total) + ']') |
| 492 | return total, count |
| 493 | |
| 494 | |
| 495 | # 清空回收站 |
no test coverage detected