diff --git a/src/py/bbctrl/Log.py b/src/py/bbctrl/Log.py index 87f694f..6fed9f7 100644 --- a/src/py/bbctrl/Log.py +++ b/src/py/bbctrl/Log.py @@ -182,4 +182,11 @@ class Log(object): if n == 16: os.unlink(fullpath) else: self._rotate(path, nextN) - os.rename(fullpath, '%s.%d' % (path, nextN)) + # The recursive call may have unlinked or rotated this + # path; tolerate a missing source rather than crashing + # bbctrl on startup. This also tolerates concurrent + # logrotate runs from /etc/cron.reboot. + try: + os.rename(fullpath, '%s.%d' % (path, nextN)) + except FileNotFoundError: + pass