A file lifecycle management method and device, electronic equipment and storage medium

By introducing a fault-tolerance mechanism into the Linux system, the pre-deletion time is calculated based on the file creation time and lifespan duration, which solves the problem of file deletion depending on the lifespan duration and improves the rationality and accuracy of file management.

CN114706815BActive Publication Date: 2026-01-20NEW H3C TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210262749.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-17
Publication Date
2026-01-20
Estimated Expiration
2042-03-17

AI Technical Summary

Technical Problem

In existing technologies, the Linux operating system lacks file lifecycle management capabilities, causing file deletion to depend on the lifecycle duration, which can easily lead to erroneous deletion, especially the unreasonable deletion of "popular" files.

Method used

A fault tolerance mechanism is introduced. By obtaining the file creation time, lifespan duration, and preset fault tolerance duration, the pre-deletion time of the file is calculated, and the deletion operation is performed at that time, avoiding reliance solely on the lifespan duration.

Benefits of technology

It reduces the occurrence of accidental file deletion, improves the rationality of file lifecycle management, and ensures that important files are not deleted prematurely.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114706815B_ABST
    Figure CN114706815B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a file lifecycle management method and device, electronic equipment and storage medium, the file creation time, the file lifecycle duration and the file storage path of the file to be managed are acquired; whether the file to be managed is expired at the current time is judged according to the file creation time and the file lifecycle duration; if the file to be managed is expired, the preset fault tolerance duration of the file to be managed is acquired; the pre-deletion time of the file to be managed is calculated according to the preset fault tolerance duration, the file creation time and the file lifecycle duration; according to the pre-deletion time, the deletion operation of the file to be managed is executed according to the file storage path. In the file lifecycle management process, by introducing the fault tolerance mechanism, the file is avoided from being deleted by mistake due to complete dependence on the deletion rule.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of document lifecycle management technology, and in particular to a document lifecycle management method, apparatus, electronic device and storage medium. Background Technology

[0002] During operation, business systems generate numerous temporary files, such as offline download cache files and backup files. These files consume storage resources, and if not deleted regularly, their accumulation significantly impacts the storage of business data. Currently, most business systems run on Linux operating systems, but Linux lacks file lifecycle management capabilities.

[0003] In existing technologies, the lifecycle duration of files is stored in a database through configuration. When a file is created, its information (such as creation time) and lifecycle duration are written to the database. The database is periodically queried to check if the file has expired; if it has, it is deleted. However, this method relies entirely on the lifecycle duration for file deletion, which can easily lead to erroneous deletion, such as premature deletion of "popular" files, resulting in inadequate file lifecycle management. Summary of the Invention

[0004] The purpose of this application is to provide a file lifecycle management method, apparatus, electronic device, and storage medium to add a fault tolerance mechanism during file deletion, thereby increasing the rationality of file lifecycle management. The specific technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a file lifecycle management method, the method comprising:

[0006] Get the file creation time, file lifespan duration, and file storage path of the file to be managed;

[0007] Based on the file creation time and the file lifespan, determine whether the file to be managed has expired at the current time;

[0008] If the file to be managed expires, then obtain the preset fault tolerance period of the file to be managed;

[0009] The pre-deletion time of the file to be managed is calculated based on the preset fault tolerance time, the file creation time, and the file lifecycle duration.

[0010] Based on the pre-deletion time, the deletion operation of the file to be managed is performed according to the file storage path.

[0011] In one possible implementation, calculating the pre-deletion time of the file to be managed based on the preset fault tolerance duration, the file creation time, and the file lifecycle duration includes:

[0012] Obtain the last operation time of the file to be managed;

[0013] Calculate the deletion extension time for the file to be managed based on the last operation time and the preset fault tolerance time.

[0014] The pre-deletion time of the file to be managed is calculated based on the file creation time, the file lifespan, and the deletion extension time.

[0015] In one possible implementation, the last operation time includes the last access time and / or the last modification time, and the initial value of the deletion extension time is 0; calculating the deletion extension time of the file to be managed based on the last operation time and the preset fault tolerance duration includes:

[0016] Calculate the difference between the current time and the last access time to obtain the first difference;

[0017] If the first difference is less than the preset fault tolerance time, the first extended time is obtained by calculating the difference between the preset fault tolerance time and the first difference.

[0018] The first extension duration is added to the current value of the deletion extension time for the file to be managed.

[0019] and / or

[0020] Calculate the difference between the current time and the last modified time to obtain the second difference;

[0021] If the second difference is less than the preset fault tolerance time, the second extended time is obtained by calculating the difference between the preset fault tolerance time and the second difference.

[0022] The second extension duration is added to the current value of the deletion extension time for the files to be managed.

[0023] In one possible implementation, the step of performing the deletion operation of the file to be managed according to the file storage path based on the pre-deletion time includes:

[0024] According to the preset deletion cycle, compare the size of the pre-deletion time with the current time;

[0025] If the pre-deletion time is not greater than the current time, calculate the difference between the current time and the file creation time to obtain a third difference;

[0026] Compare the third difference with the preset fault tolerance duration, wherein the preset fault tolerance duration is greater than the file lifecycle duration;

[0027] If the third difference is not less than the preset fault tolerance time, then the deletion operation of the file to be managed is performed according to the file storage path.

[0028] In one possible implementation, the method further includes:

[0029] If the third difference is less than the preset fault tolerance time, then the third extended time is obtained by calculating the difference between the preset fault tolerance time and the third difference.

[0030] The target time value is obtained by adding a third extension duration to the current time.

[0031] Update the value of the pre-deletion time of the file to be managed to the target time value.

[0032] In one possible implementation, after the step of calculating the pre-deletion time of the file to be managed based on the preset fault tolerance duration, the file creation time, and the file lifecycle duration, the method further includes:

[0033] Add the pre-deletion time of the file to be managed to a pre-established temporary deletion list;

[0034] The step of comparing the size of the pre-deletion time with the current time according to the preset deletion period includes:

[0035] According to the preset deletion cycle, the pre-deletion time of the file to be managed is read from the temporary deletion list, and the size of the pre-deletion time is compared with the current time.

[0036] In one possible implementation, the method further includes:

[0037] During the creation of the file to be managed, the file creation time, file lifecycle duration, and file storage path of the file to be managed are obtained;

[0038] The file creation time, file lifecycle duration, and file storage path of the file to be managed are used as metadata of the file to be managed and added to the metadata information of the file to be managed.

[0039] The process of obtaining the file creation time, file lifecycle duration, and file storage path of the file to be managed includes:

[0040] Obtain the file creation time, file lifecycle duration, and file storage path of the file to be managed from the metadata information of the file to be managed.

[0041] Secondly, embodiments of this application provide a file lifecycle management device, the device comprising:

[0042] The acquisition module is used to obtain the file creation time, file lifecycle duration, and file storage path of the file to be managed;

[0043] The expiration determination module is used to determine whether the file to be managed has expired at the current time based on the file's creation time and the file's lifespan.

[0044] The preset fault tolerance duration acquisition module is used to acquire the preset fault tolerance duration of the file to be managed if the file to be managed expires.

[0045] The pre-deletion time calculation module is used to calculate the pre-deletion time of the file to be managed based on the preset fault tolerance time, the file creation time, and the file life cycle duration.

[0046] The deletion module is used to perform the deletion operation of the file to be managed according to the file storage path based on the pre-deletion time.

[0047] In one possible implementation, the pre-deletion time calculation module is specifically used for:

[0048] Obtain the last operation time of the file to be managed;

[0049] Calculate the deletion extension time for the file to be managed based on the last operation time and the preset fault tolerance time.

[0050] The pre-deletion time of the file to be managed is calculated based on the file creation time, the file lifespan, and the deletion extension time.

[0051] In one possible implementation, the last operation time includes the last access time and / or the last modification time, and the initial value of the deletion extension time is 0; the pre-deletion time calculation module is further used for:

[0052] Calculate the difference between the current time and the last access time to obtain the first difference;

[0053] If the first difference is less than the preset fault tolerance time, the first extended time is obtained by calculating the difference between the preset fault tolerance time and the first difference.

[0054] The first extension duration is added to the current value of the deletion extension time for the file to be managed.

[0055] and / or

[0056] Calculate the difference between the current time and the last modified time to obtain the second difference;

[0057] If the second difference is less than the preset fault tolerance time, the second extended time is obtained by calculating the difference between the preset fault tolerance time and the second difference.

[0058] The second extension duration is added to the current value of the deletion extension time for the files to be managed.

[0059] In one possible implementation, the deletion module is specifically used for:

[0060] According to the preset deletion cycle, compare the size of the pre-deletion time with the current time;

[0061] If the pre-deletion time is not greater than the current time, calculate the difference between the current time and the file creation time to obtain a third difference;

[0062] Compare the third difference with the preset fault tolerance duration, wherein the preset fault tolerance duration is greater than the file lifecycle duration;

[0063] If the third difference is not less than the preset fault tolerance time, then the deletion operation of the file to be managed is performed according to the file storage path.

[0064] In one possible implementation, the deletion module is further configured to:

[0065] If the third difference is less than the preset fault tolerance time, then the third extended time is obtained by calculating the difference between the preset fault tolerance time and the third difference.

[0066] The target time value is obtained by adding a third extension duration to the current time.

[0067] Update the value of the pre-deletion time of the file to be managed to the target time value.

[0068] In one possible implementation, the device further includes an expiration determination module, used for:

[0069] Add the pre-deletion time of the file to be managed to a pre-established temporary deletion list;

[0070] The step of comparing the size of the pre-deletion time with the current time according to the preset deletion period includes:

[0071] According to the preset deletion cycle, the pre-deletion time of the file to be managed is read from the temporary deletion list, and the size of the pre-deletion time is compared with the current time.

[0072] In one possible implementation, the apparatus further includes a metadata addition module for:

[0073] During the creation of the file to be managed, the file creation time, file lifecycle duration, and file storage path of the file to be managed are obtained; the file creation time, file lifecycle duration, and file storage path of the file to be managed are used as the metadata of the file to be managed and added to the metadata information of the file to be managed.

[0074] The acquisition module is further configured to: obtain the file creation time, file lifecycle duration, and file storage path of the file to be managed from the metadata information of the file to be managed.

[0075] Thirdly, embodiments of this application provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0076] Memory, used to store computer programs;

[0077] The processor, when executing a program stored in memory, implements any of the file lifecycle management methods described in this application.

[0078] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the file lifecycle management methods described in this application.

[0079] Beneficial effects of the embodiments in this application:

[0080] The file lifecycle management method provided in this application can obtain the file creation time, file lifecycle duration, and file storage path of a file to be managed; determine whether the file to be managed has expired at the current time based on the file creation time and the file lifecycle duration; when the file to be managed has expired, obtain the preset fault tolerance duration of the file to be managed; calculate the pre-deletion time of the file to be managed based on the preset fault tolerance duration, the file creation time, and the file lifecycle duration; and finally, execute the deletion operation of the file to be managed according to the file storage path based on the pre-deletion time. It can be seen that in this application, by obtaining the preset fault tolerance duration of expired files to be managed, and determining the pre-deletion time of the files to be managed based on the preset fault tolerance duration, the file creation time, and the file lifecycle duration, a fault tolerance mechanism is introduced through the preset fault tolerance duration. This makes file deletion not entirely dependent on the file lifecycle duration, reducing the possibility of erroneous file deletion and increasing the rationality of file lifecycle management.

[0081] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0082] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0083] Figure 1 This is a first schematic diagram of a file lifecycle management method according to an embodiment of this application;

[0084] Figure 2 This is a schematic diagram illustrating one possible implementation of step S14 in an embodiment of this application;

[0085] Figure 3 This is a schematic diagram illustrating one possible implementation of step S15 in an embodiment of this application;

[0086] Figure 4 This is a second schematic diagram of the file lifecycle management method according to an embodiment of this application;

[0087] Figure 5 This is a third schematic diagram of the file lifecycle management method according to an embodiment of this application;

[0088] Figure 6 This is a schematic diagram of a file lifecycle management device according to an embodiment of this application;

[0089] Figure 7 This is a schematic diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0090] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.

[0091] To avoid managing file lifecycles solely based on lifecycle duration and to improve the rationality of file lifecycle management, this application provides a file lifecycle management method, see [link to relevant documentation]. Figure 1 The method includes:

[0092] S11, obtain the file creation time, file lifecycle duration and file storage path of the file to be managed.

[0093] The file lifecycle management method in this application embodiment can be implemented using an electronic device running a Linux system. Specifically, the electronic device can be a smartphone, smart gateway, router, personal computer, or server, etc. Multiple business systems can run on the electronic device, and each business system generates files to be managed during its operation. The file lifecycle management method in this application embodiment is only described using the lifecycle management process of one file to be managed as an example. The file lifecycle management method of this application embodiment can be executed for each file to be managed.

[0094] The files to be managed can be any file in the Linux system that requires lifecycle management. For example, in a log system within a Linux system, the files to be managed can include log files; similarly, in an alarm system within a Linux system, the files to be managed can include alarm files.

[0095] During the creation of files to be managed, the file creation time, file lifecycle duration, and file storage path can be obtained. The file lifecycle duration indicates how long the file needs to be retained, and can be customized according to actual needs. In one example, it can be set according to the type of file to be managed and the type of business system. The more important the file to be managed, the longer its file lifecycle duration can be. For example, the file lifecycle duration of alarm files is longer than that of log files.

[0096] During the lifecycle management of files to be managed, the file creation time, lifecycle duration, and storage path can be obtained according to preset detection cycles, such as 1 second, 2 seconds, and 10 seconds. Multiple business systems running on an electronic device typically have different preset detection cycles. Alternatively, the lifecycle management of files to be managed can also be performed when the electronic device's memory usage reaches a preset threshold, at which point the file creation time, lifecycle duration, and storage path can be obtained.

[0097] S12, based on the file creation time and the file lifecycle duration, determine whether the file to be managed has expired at the current time.

[0098] If the sum of the file's creation time and its lifespan is not greater than the current time, then the file has expired. For example, if a file was created at 15:00, has a lifespan of 20 minutes, and the current time is 15:30, then according to the rule that 15:20 is not greater than 15:30, the file has expired. If the sum of the file's creation time and its lifespan is greater than the current time, then the system continues to check if other files under management have expired.

[0099] S13, if the file to be managed has expired, then obtain the preset fault tolerance period of the file to be managed.

[0100] When a file to be managed expires, it is not directly deleted. Each file has a preset fault tolerance period. This preset fault tolerance period prevents accidental deletion based solely on the file's lifespan. The preset fault tolerance period for managed files can be customized according to actual needs. In one example, managed files of the same type have the same preset fault tolerance period, while managed files of different types have different preset fault tolerance periods. For example, log files m1 and m2 have the same preset fault tolerance period; alarm files n1, n2, and n3 have the same preset fault tolerance period, but the preset fault tolerance period for log files differs from that for alarm files. In another example, the preset fault tolerance period is longer than the file's lifespan.

[0101] S14. Calculate the pre-deletion time of the file to be managed based on the preset fault tolerance time, the file creation time, and the file lifecycle duration.

[0102] According to a preset algorithm, the pre-deletion time of the file to be managed is calculated based on the preset fault tolerance time, file creation time, and file lifespan. The preset algorithm can be customized according to actual needs; in one possible implementation, see [link to implementation details]. Figure 2 The pre-deletion time of the files to be managed can be calculated in the following way:

[0103] S141, Obtain the last operation time of the file to be managed.

[0104] S142, calculate the deletion extension time of the file to be managed based on the last operation time and the preset fault tolerance time.

[0105] The last operation time includes the last access time and / or the last modification time.

[0106] In one example, the difference between the current time and the last operation time can be calculated. If the difference is less than the preset fault tolerance time, the difference between the preset fault tolerance time and the difference can be calculated to obtain the deletion extension time.

[0107] In one possible implementation, calculating the deletion extension time for the file to be managed based on the last operation time and the preset fault tolerance duration includes:

[0108] Step 1: Calculate the difference between the current time and the last access time to obtain the first difference;

[0109] Step 2: If the first difference is less than the preset fault tolerance time, the first extended time is obtained by calculating the difference between the preset fault tolerance time and the first difference.

[0110] Step 3: Add the first extension duration to the current value of the deletion extension time for the file to be managed, wherein the initial value of the deletion extension time is 0;

[0111] and / or

[0112] Step 4: Calculate the difference between the current time and the last modified time to obtain the second difference;

[0113] Step 5: If the second difference is less than the preset fault tolerance time, the second extended time is obtained by calculating the difference between the preset fault tolerance time and the second difference.

[0114] Step 6: Add the second extension duration to the current value of the deletion extension time for the file to be managed.

[0115] The initial value of the deletion extension time is 0. When the last operation time includes the last access time, the difference between the current time and the last access time is calculated to obtain the first difference. It is then determined whether the first difference is less than the preset fault tolerance time. If so, the first extension time is obtained by calculating the difference between the preset fault tolerance time and the first difference. In one example, a first weight p1 can be preset for the difference between the preset fault tolerance time and the first difference. The first extension time is obtained by multiplying the difference between the preset fault tolerance time and the first difference by p1. If the first difference is greater than or equal to the preset fault tolerance time, the deletion extension time of the file to be managed is not modified based on the first difference.

[0116] When the last operation time is the same as the last access time, the difference between the current time and the last modification time is calculated to obtain a second difference. It is then determined whether this second difference is less than a preset fault tolerance period. If so, a second extension period is obtained by calculating the difference between the preset fault tolerance period and the second difference. In one example, a second weight p2 can be pre-set for the difference between the preset fault tolerance period and the second difference. The second extension period is obtained by multiplying the difference between the preset fault tolerance period and the second difference by p2. If the second difference is greater than or equal to the preset fault tolerance period, the deletion extension period for the file to be managed is not modified based on the second difference. In one example, the sum of p1 and p2 is 1.

[0117] For example, if the last operation time is the last access time of 15:15 and the current time is 15:30, the first difference is 15 minutes, which is less than the preset fault tolerance time of 25 minutes. That is, the first difference is less than the preset fault tolerance time. Then, the first extension time is calculated. The first extension time is the difference between the preset fault tolerance time and the first difference, which is equal to 10 minutes. The deletion extension time of the file to be managed is the current value of the deletion extension time plus the first extension time. Since the initial value of the deletion extension time is 0, the deletion extension time of the file to be managed is 10 minutes.

[0118] When the last operation time is the last modification time of 15:10, the second difference is 20 minutes, which is less than the preset fault tolerance time of 25 minutes. Therefore, the second extension time is calculated as the difference between the preset fault tolerance time and the second difference, which is 5 minutes. The deletion extension time for the file to be managed is the current deletion extension time plus the second extension time. If a first extension time exists, the current deletion extension time is the first extension time, and the calculated deletion extension time is the first extension time plus the second extension time. If a first extension time does not exist, it means there is no last access time, or the first difference between the last access time and the current time is not less than the preset fault tolerance time, and the current deletion extension time is the initial value of 0. The calculated deletion extension time is the second extension time.

[0119] Of course, there may be no second extension period, in which case the extension time for deleting the file to be managed is the first extension period.

[0120] If neither the first extension duration nor the second extension duration exists, the deletion extension time for the file to be managed will be the initial value of 0.

[0121] The pre-deletion time is the sum of the file creation time of the file to be managed, the file lifecycle duration, and the deletion extension time. After obtaining the pre-deletion time, the pre-deletion time of the file to be managed can also be added to a pre-established temporary deletion list.

[0122] See Figure 2 S143, calculate the pre-deletion time of the file to be managed based on the file creation time, the file lifespan duration, and the deletion extension time.

[0123] In one example, the sum of the file creation time, file lifespan, and deletion extension time can be calculated as the pre-deletion time for the file to be managed.

[0124] In the embodiments of this application, the last operation time is introduced in the process of calculating the pre-deletion time, taking into account the popularity of the file, so that the deletion of the file does not completely depend on the life cycle of the file. For example, for "popular" files, the last operation time of the file will be continuously updated as the file is continuously operated on. Therefore, the duration of the deletion extension can be increased, thereby reducing the situation of accidental file deletion and further increasing the rationality of file life cycle management.

[0125] See Figure 1 S15: Based on the pre-deletion time, perform the deletion operation of the file to be managed according to the file storage path.

[0126] In one example, when the system's current time reaches the pre-deletion time, the deletion operation for the file to be managed can be performed according to the file storage path of the file to be managed.

[0127] In one example, when the system's current time reaches the pre-deletion time, it can also determine whether to perform a deletion operation on the file to be managed based on a preset fault tolerance period. In one possible implementation, see [link to implementation details]. Figure 3 The step of performing the deletion operation of the file to be managed according to the pre-deletion time and the file storage path includes:

[0128] S151, according to the preset deletion cycle, compare the size of the pre-deletion time with the current time.

[0129] Multiple business systems can run in an electronic device. Different business systems can detect files to be managed according to different preset detection cycles and calculate the pre-deletion time for the files to be managed. Of course, each business system can also use the same preset detection cycle.

[0130] The preset deletion cycle can be customized according to actual needs. In one example, file deletion operations can be independent of individual business systems. All files to be managed can be added to a pre-established temporary deletion list at their pre-deletion time. Electronic devices can then delete all files based on this temporary deletion list at a preset deletion cycle. In one possible implementation, see [link to implementation details]. Figure 4 After the step of calculating the pre-deletion time of the file to be managed based on the preset fault tolerance time, the file creation time, and the file lifecycle time, the method further includes:

[0131] S41, add the pre-deletion time of the file to be managed to the pre-established temporary deletion list.

[0132] The step of comparing the size of the pre-deletion time with the current time according to the preset deletion period includes:

[0133] S1511, according to the preset deletion cycle, read the pre-deletion time of the file to be managed from the temporary deletion list, and compare the size of the pre-deletion time with the current time.

[0134] Since the pre-deletion time has been added to the temporary deletion list, this step involves reading the pre-deletion time of the files to be managed from the temporary deletion list according to a preset deletion cycle, and comparing the size of the pre-deletion time with the current time. In this embodiment, the temporary deletion list includes the pre-deletion times of files to be managed generated by different business systems. The temporary deletion list can be traversed within each preset deletion cycle, and the size of the pre-deletion time of each file in the temporary deletion list can be compared with the current time.

[0135] See Figure 3 S152, if the pre-deletion time is not greater than the current time, calculate the difference between the current time and the file creation time to obtain a third difference.

[0136] If the current time is 16:10 and the pre-deletion time of the file to be managed is 16:15, meaning the pre-deletion time is greater than the current time, this indicates that the pre-deletion time of the file to be managed has not yet arrived. In this case, no further operations will be performed on the file to be managed within the current preset deletion cycle. Instead, the file to be managed will be compared with the current time in the next preset deletion cycle. If the pre-deletion time of the file to be managed is 16:00 and the current time is 16:10, meaning the pre-deletion time is not greater than the current time, then the difference between the current time and the file creation time needs to be calculated to obtain a third difference. For example, if the file creation time is 15:55, then the third difference can be 16:10 - 15:55 = 15 minutes.

[0137] S153, compare the third difference with the preset fault tolerance duration, wherein the preset fault tolerance duration is greater than the file lifecycle duration.

[0138] By comparing the third difference with the preset fault tolerance time, it can be determined whether the file to be managed has been created a long time ago.

[0139] S154, if the third difference is not less than the preset fault tolerance time, then the deletion operation of the file to be managed is performed according to the file storage path.

[0140] If the third difference is not less than the preset fault tolerance time, it means that the file to be managed has been created for a long time. In this case, delete the file to be managed according to the file storage path.

[0141] In one possible implementation, see Figure 3 The method further includes:

[0142] S155, if the third difference is less than the preset fault tolerance time, then the third extended time is obtained by calculating the difference between the preset fault tolerance time and the third difference.

[0143] If the third difference is less than the preset fault tolerance time, it indicates that the file to be managed was created recently. Therefore, the pre-deletion time of the file to be managed can be extended. Specifically, the difference between the preset fault tolerance time and the third difference can be calculated as the third extension time.

[0144] S156, add a third extension duration to the current time to obtain the target time value.

[0145] Taking a third difference of 15 minutes, a preset fault tolerance time of 25 minutes, and the current time of 16:10 as an example, the third extension time is 10 minutes. Therefore, the target time value of the file to be managed is 16:20.

[0146] S157, update the value of the pre-deletion time of the file to be managed to the target time value.

[0147] Once the target time value for the file to be managed is determined, the pre-deletion time of the file becomes that target time value. The pre-deletion time corresponding to the file in the temporary deletion list is then updated to the target time value. After the pre-deletion time of the file to be managed is updated, the file will not be processed within the current preset deletion cycle; instead, it will be processed in the next preset deletion cycle.

[0148] After processing the files to be managed, if there are other files in the temporary deletion list that have not been traversed, then within the current preset deletion cycle, the other files can be processed in the same way as the files to be managed, until every file in the temporary deletion list has been traversed.

[0149] The file creation time, file lifecycle duration, and file storage path of the file to be managed can be used as metadata and added to the metadata information of the file to be managed. The metadata information can be stored in the Linux operating system as a file.

[0150] In one possible implementation, see Figure 5 The method further includes:

[0151] S51, during the process of creating the file to be managed, obtain the file creation time, file lifecycle duration and file storage path of the file to be managed;

[0152] S52, the file creation time, file lifecycle duration, and file storage path of the file to be managed are used as metadata of the file to be managed and added to the metadata information of the file to be managed.

[0153] The process of obtaining the file creation time and file lifecycle duration of the file to be managed includes:

[0154] S111, obtain the file creation time, file lifecycle duration, and file storage path of the file to be managed from the metadata information of the file to be managed.

[0155] For files requiring lifecycle management, i.e., files to be managed, when the business system creates a file to be managed, it adds additional metadata information to the file's metadata information. This additional metadata information includes the file storage path (e.g., an absolute path), file creation time, and file lifecycle. The metadata information of the files to be managed can be stored as a file in the Linux operating system for later retrieval.

[0156] In this embodiment, the file creation time, file lifecycle duration, and file storage path of the files to be managed are stored as metadata information, which can be done without relying on the business system's database. Subsequently, in conjunction with a temporary deletion list, file lifecycle management can be completed without relying on the business system's database.

[0157] This application also provides a file lifecycle management device, see [link to relevant documentation]. Figure 6 The device includes:

[0158] The acquisition module 601 is used to acquire the file creation time, file lifespan duration, and file storage path of the file to be managed.

[0159] The expiration determination module 602 is used to determine whether the file to be managed has expired at the current time based on the file creation time and the file life cycle duration.

[0160] The preset fault tolerance duration acquisition module 603 is used to acquire the preset fault tolerance duration of the file to be managed if the file to be managed expires.

[0161] The pre-deletion time calculation module 604 is used to calculate the pre-deletion time of the file to be managed based on the preset fault tolerance time, the file creation time, and the file life cycle duration.

[0162] The deletion module 605 is used to perform the deletion operation of the file to be managed according to the file storage path based on the pre-deletion time.

[0163] In one possible implementation, the pre-deletion time calculation module 604 is specifically used to: obtain the last operation time of the file to be managed; calculate the deletion extension time of the file to be managed based on the last operation time and the preset fault tolerance duration; and calculate the pre-deletion time of the file to be managed based on the file creation time, the file lifecycle duration, and the deletion extension time.

[0164] In one possible implementation, the last operation time includes the last access time and / or the last modification time, and the initial value of the deletion extension time is 0; the pre-deletion time calculation module 604 is further configured to calculate the difference between the current time and the last access time to obtain a first difference; if the first difference is less than the preset fault tolerance time, a first extension time is obtained by calculating the difference between the preset fault tolerance time and the first difference; the first extension time is added to the current value of the deletion extension time of the file to be managed; and / or, the difference between the current time and the last modification time is calculated to obtain a second difference; if the second difference is less than the preset fault tolerance time, a second extension time is obtained by calculating the difference between the preset fault tolerance time and the second difference; the second extension time is added to the current value of the deletion extension time of the file to be managed.

[0165] In one possible implementation, the deletion module 605 is specifically configured to: compare the size of the pre-deletion time with the current time according to a preset deletion cycle; if the pre-deletion time is not greater than the current time, calculate the difference between the current time and the file creation time to obtain a third difference; compare the third difference with the size of a preset fault tolerance period, wherein the preset fault tolerance period is greater than the file lifecycle duration; if the third difference is not less than the preset fault tolerance period, then perform the deletion operation of the file to be managed according to the file storage path.

[0166] In one possible implementation, the deletion module 605 is further configured to: if the third difference is less than the preset fault tolerance time, calculate the difference between the preset fault tolerance time and the third difference to obtain a third extended time; add the third extended time to the current time to obtain a target time value; and update the value of the pre-deletion time of the file to be managed to the target time value.

[0167] In one possible implementation, the device further includes an expiration determination module, configured to: add the pre-deletion time of the file to be managed to a pre-established temporary deletion list; and compare the size of the pre-deletion time with the current time according to a preset deletion cycle, comprising: reading the pre-deletion time of the file to be managed from the temporary deletion list according to the preset deletion cycle, and comparing the size of the pre-deletion time with the current time.

[0168] In one possible implementation, the device further includes a metadata adding module, configured to: during the creation of the file to be managed, obtain the file creation time, file lifecycle duration, and file storage path of the file to be managed; and add the file creation time, file lifecycle duration, and file storage path of the file to be managed as metadata of the file to be managed to the metadata information of the file to be managed. The obtaining module 601 is further configured to: obtain the file creation time, file lifecycle duration, and file storage path of the file to be managed from the metadata information of the file to be managed.

[0169] This application also provides an electronic device, such as... Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703, and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.

[0170] Memory 703 is used to store computer programs;

[0171] The processor 701, when executing a program stored in the memory 703, implements any of the file lifecycle management methods in this application.

[0172] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0173] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0174] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0175] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0176] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements any of the file lifecycle management methods in this application.

[0177] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the file lifecycle management methods in this application.

[0178] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0179] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0180] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0181] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.

Claims

1. A method of file lifecycle management, characterized by, The method comprises: acquiring a file creation time, a file life cycle length and a file storage path of a to-be-managed file; judging whether the to-be-managed file is expired at a current time according to the file creation time and the file life cycle length; if the to-be-managed file is expired, acquiring a preset fault tolerance length of the to-be-managed file; calculating a pre-deletion time of the to-be-managed file according to the preset fault tolerance length, the file creation time and the file life cycle length; performing a deletion operation of the to-be-managed file according to the file storage path and the pre-deletion time; the calculating of the pre-deletion time of the to-be-managed file according to the preset fault tolerance length, the file creation time and the file life cycle length comprises: acquiring a last operation time of the to-be-managed file; calculating a deletion extension time of the to-be-managed file according to the last operation time and the preset fault tolerance length; calculating a pre-deletion time of the to-be-managed file according to the file creation time, the file life cycle length and the deletion extension time; the performing of the deletion operation of the to-be-managed file according to the pre-deletion time and the file storage path comprises: comparing the pre-deletion time with a current time according to a preset deletion period; if the pre-deletion time is not greater than the current time, calculating a difference between the current time and the file creation time to obtain a third difference value; comparing the third difference value with the preset fault tolerance length, wherein the preset fault tolerance length is greater than the file life cycle length; if the third difference value is not less than the preset fault tolerance length, performing the deletion operation of the to-be-managed file according to the file storage path.

2. The method of claim 1, wherein, the last operation time comprises a last access time and / or a last modification time, and an initial value of the deletion extension time is 0; the calculating of the deletion extension time of the to-be-managed file according to the last operation time and the preset fault tolerance length comprises: calculating a first difference value between a current time and the last access time; if the first difference value is less than the preset fault tolerance length, calculating a first extension length by calculating a difference between the preset fault tolerance length and the first difference value; increasing the first extension length on a current value of the deletion extension time of the to-be-managed file; and / or calculating a second difference value between a current time and the last modification time; if the second difference value is less than the preset fault tolerance length, calculating a second extension length by calculating a difference between the preset fault tolerance length and the second difference value; increasing the second extension length on the current value of the deletion extension time of the to-be-managed file. the method further comprises:

3. The method of claim 1, wherein, if the third difference value is less than the preset fault tolerance length, calculating a third extension length by calculating a difference between the preset fault tolerance length and the third difference value; increasing the third extension length on a current time to obtain a target time value; updating a value of the pre-deletion time of the to-be-managed file to the target time value. ​ 4. The method of claim 1, wherein, After the step of calculating the pre-deletion time of the to-be-managed file according to the preset fault tolerance time length, the file creation time and the file life cycle time length, the method further comprises: adding the pre-deletion time of the to-be-managed file to a pre-established temporary deletion list; The step of comparing the pre-deletion time with the current time according to the preset deletion period comprises: reading the pre-deletion time of the to-be-managed file from the temporary deletion list according to the preset deletion period, and comparing the pre-deletion time with the current time.

5. The method of claim 1, wherein, The method further comprises: obtaining the file creation time, the file life cycle time length and the file storage path of the to-be-managed file in the process of creating the to-be-managed file; adding the file creation time, the file life cycle time length and the file storage path of the to-be-managed file as metadata of the to-be-managed file to the metadata information of the to-be-managed file; The step of obtaining the file creation time, the file life cycle time length and the file storage path of the to-be-managed file comprises: obtaining the file creation time, the file life cycle time length and the file storage path of the to-be-managed file from the metadata information of the to-be-managed file.

6. A file lifecycle management apparatus, characterized by, The device comprises: an obtaining module configured to obtain the file creation time, the file life cycle time length and the file storage path of the to-be-managed file; an expiration judging module configured to judge whether the to-be-managed file is expired at the current time according to the file creation time and the file life cycle time length; a preset fault tolerance time length obtaining module configured to obtain a preset fault tolerance time length of the to-be-managed file if the to-be-managed file is expired; a pre-deletion time calculating module configured to calculate the pre-deletion time of the to-be-managed file according to the preset fault tolerance time length, the file creation time and the file life cycle time length; a deleting module configured to execute the deletion operation of the to-be-managed file according to the pre-deletion time and the file storage path; The pre-deletion time calculating module is specifically configured to: obtain the last operation time of the to-be-managed file; calculate the deletion extension time of the to-be-managed file according to the last operation time and the preset fault tolerance time length; and calculate the pre-deletion time of the to-be-managed file according to the file creation time, the file life cycle time length and the deletion extension time. The deleting module is specifically configured to: compare the pre-deletion time with the current time according to the preset deletion period; calculate the difference between the current time and the file creation time to obtain a third difference value if the pre-deletion time is not greater than the current time; compare the third difference value with the preset fault tolerance time length, wherein the preset fault tolerance time length is greater than the file life cycle time length; and execute the deletion operation of the to-be-managed file according to the file storage path if the third difference value is not less than the preset fault tolerance time length.

7. An electronic device, comprising: The device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus; the memory is used for storing a computer program; A processor for implementing the method steps of any one of claims 1-5 when the processor executes a program stored on a memory.

8. A computer-readable storage medium, characterized in that, A computer program stored in the computer readable storage medium, the computer program being executed by a processor to implement the method steps of any one of claims 1-5.

Citation Information

Patent Citations

  • Data management method and device, electronic equipment and readable storage medium

    CN111124952A