Skip to content

Commit

Permalink
remove the old history files over 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sujinmkang committed Nov 18, 2020
1 parent c607ca0 commit 43e0bd3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sonic-host-services/scripts/process-reboot-cause
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
#
# process-reboot-cause
#
Expand Down Expand Up @@ -49,7 +49,7 @@ def read_reboot_cause_files_and_save_state_db():

data = []
# Read each sorted previous reboot cause file and update the state db with previous reboot cause information
for i in range(min(10,len(TIME_SORTED_FULL_REBOOT_FILE_LIST))) :
for i in range(min(10,len(TIME_SORTED_FULL_REBOOT_FILE_LIST))):
x = TIME_SORTED_FULL_REBOOT_FILE_LIST[i]
if os.path.isfile(x):
with open(x, "r") as cause_file:
Expand All @@ -60,6 +60,12 @@ def read_reboot_cause_files_and_save_state_db():
state_db.set(state_db.STATE_DB, _hash, 'user', data['user'])
state_db.set(state_db.STATE_DB, _hash, 'comment', data['comment'])

if len(TIME_SORTED_FULL_REBOOT_FILE_LIST) > 10:
for i in range(len(TIME_SORTED_FULL_REBOOT_FILE_LIST)):
if i >= 10:
x = TIME_SORTED_FULL_REBOOT_FILE_LIST[i]
os.remove(x)


def main():
# Configure logger to log all messages INFO level and higher
Expand Down

0 comments on commit 43e0bd3

Please sign in to comment.