diff --git a/mbtk/mbtk_logd/common.c b/mbtk/mbtk_logd/common.c
index 5b2de92..56df064 100755
--- a/mbtk/mbtk_logd/common.c
+++ b/mbtk/mbtk_logd/common.c
@@ -190,70 +190,46 @@
  */
 int get_rotate_file(int fd, char *base_file, struct file_list_t *_file_list)
 {
-    char _time[16] = {0};
-    int num = 0;
-    char tmp_buf[48] = {0};
-    char *current_file = _file_list->file[_file_list->current];
-    int len = strlen(base_file);
-    char *old = malloc(len + 20);
-    int rotate_file_count_max;
+    char old_name[32] = {0}; 
+    char new_name[32] = {0};
 
+    
+    int rotate_file_count_max = 0;
+    
     if(_file_list->total == -1 || _file_list->total == 0 || _file_list->total > ROTATE_FILE_COUNT_MAX)
+    {
         rotate_file_count_max = ROTATE_FILE_COUNT_MAX;
+    }
     else
+    {
         rotate_file_count_max = _file_list->total;
-
-
-    if(0 == _file_list->current && NULL == current_file)
-        _file_list->current = rotate_file_count_max - 1;
-    if(NULL == old)
-    {
-        fprintf(stderr, "failed to malloc %s\n", strerror(errno));
-        exit(-1);
     }
-    close(fd);
-    sprintf(tmp_buf, "/tmp/log%s", strstr_tail(base_file, "/"));
-    get_time(_time);
-    sprintf(old, "%s.%s", base_file, _time);
-    if (current_file && strstr(current_file, old)) {
-        int tmp_len = strlen(current_file);
-        //  以时间命名的文件是否已经存在
-        if(current_file[tmp_len - 3] == '.'){
-            num = atoi(&current_file[tmp_len - 2]);
-            num++;
-            sprintf(old, "%s.%02d", old, num);
-        }else{
-            sprintf(old, "%s.%02d", old, num);
+    
+    
+    snprintf(new_name, sizeof(new_name), "%s.%d", base_file, rotate_file_count_max - 1);
+    remove(new_name);
+
+    for (int i = rotate_file_count_max - 2; i >= 0; i--) 
+    {
+        if (i == 0) 
+        {
+            snprintf(old_name, sizeof(old_name), "%s", base_file);
+        } 
+        else 
+        {
+            snprintf(old_name, sizeof(old_name), "%s.%d", base_file, i - 1);
         }
-    }
-    printf("MBTK_LOGD: tmp_buf is %s, old is %s\n", tmp_buf, old);
-    if (movefile(tmp_buf, old) != 0){
-        printf("%s %d: Renamed error ,%s to %s.\n", __FUNCTION__, __LINE__, tmp_buf, old);
-    }
-    _file_list->current++;
-    // ringbuf
-    if(_file_list->current > (rotate_file_count_max - 1))
-    {
-        _file_list->current = 0;
-    }
-    // 如果之前已经存在，先释放之前存放的资源
-    if(_file_list->file[_file_list->current])
-    {
-        // printf("%s %d: remove %s\n", __FUNCTION__, __LINE__, _file_list->file[_file_list->current]);
-        // 如果 不限制文件数目，则不删除文件
-        if(_file_list->total != -1)
-            unlink(_file_list->file[_file_list->current]);
-        free(_file_list->file[_file_list->current]);
-    }
-    // 将文件名保存下来
-    _file_list->file[_file_list->current] = strdup(old);
-    free(old);
-    int fd_new = open(tmp_buf, O_CREAT | O_WRONLY | O_APPEND, 0600);
-    if (fd_new < 0) {
-        fprintf(stderr, "failed to open %s: %s\n", tmp_buf, strerror(errno));
-        exit(-1);
+        snprintf(new_name, sizeof(new_name), "%s.%d", base_file, i);
+        rename(old_name, new_name);
     }
 
+    close(fd);
+    int fd_new = open(base_file, O_CREAT | O_WRONLY | O_APPEND, 0600);
+    if (fd_new < 0) 
+    {
+        fprintf(stderr, "failed to open %s: %s\n", base_file, strerror(errno));
+        exit(-1);
+   }
     return fd_new;
 }
 
