An automatic disk cleaning method for IoT edge servers
By setting up timing tasks on IoT edge servers and grading disk cleaning based on disk usage, the problem of insufficient disk space on edge servers is solved, maintaining the healthy state of the disk and reducing the risk of data loss.
Patent Information
- Application Number
- CN202210588849.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2042-05-26
AI Technical Summary
The lack of disk space on the edge server of IoT edge servers leads to the need to automatically clean up the disk, but you have to worry about data loss.
Set up a timing task on the Internet of Things edge server, triggering every 30 minutes, dividing the system into different levels according to the current disk usage rate, and formulating corresponding disk cleaning strategies, including logs, files and database cleaning.
By automatically cleaning up the disk, keeping the disks of the edge server in a healthy and available state, the risk of data loss is reduced, and whether to automatically clean up is determined based on the type of program to prevent code errors caused by running too quickly.
Smart Images

Figure CN114840147B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of servers, and in particular to an automatic disk cleaning method for an edge server of an Internet of Things. Background Art
[0002] The deployment location of IoT edge servers is mostly consistent with the location of actual devices, and there are many edge servers distributed in different places. This leads to a high cost for edge server maintenance. Disks are limited. As the usage time increases, the disks will definitely be exhausted. Disk cleaning may cause data loss, but it has to be cleaned. As the data of the machine accumulates, the disk may run out of space. Therefore, there needs to be a way to automatically clean up the disk space. Summary of the invention
[0003] The purpose of the present invention is to provide a method for automatically cleaning a disk of an Internet of Things edge server to solve the problems raised in the above background technology.
[0004] In order to solve the above technical problems, the present invention provides the following technical solutions: a method for automatically cleaning a disk of an IoT edge server, comprising step S0, setting a scheduled task on the IoT edge server, which is triggered every 30 minutes;
[0005] Step S1, divide the system into different levels according to the current disk usage, set the range in advance in the program, and only clean up the files within the range;
[0006] Step S2: Different disk cleanup strategies can be triggered according to different levels, and the strategies are divided into three situations.
[0007] According to the above technical solution, in the above step S2, the three situations are:
[0008] S2-1, Level 1 includes a log cleanup strategy, which retains logs within 7 days;
[0009] S2-2, Level 2 includes a log cleanup strategy, which retains logs within 3 days and cleans up some persistent files and photos, retaining files and photos from the last 2 months;
[0010] S2-3, Level 3 includes the data cleanup strategy for the database, which involves cleaning up the historical retained data in the database tables.
[0011] According to the above technical solution, in the above step S2, the specific content of log cleaning is the log of OS service, the log of Linux system, and the disk partition capacity>50%;
[0012] The specific contents of file / image cleanup include unused Docker images, temporarily uploaded and stored files, and disk partition capacity > 60%;
[0013] The specific content of database cleaning is kafka, influxdb, mysql historical data cleaning, and disk partition capacity > 80%.
[0014] According to the above technical solution, at the current running speed, the number of times the cache files are reduced per unit time is recorded as a negative number a1, and the number of times the cache files are increased per unit time is recorded as a positive number a2. After each unit time, the number of times the cache files are increased and the number of times the cache files are reduced within the unit time are added together, that is, a1+a2.
[0015] According to the above technical solution, the cleaning status includes: the number of cleaning times n, the cleaned data capacity h and the cleaning time t. The relationship between the cleaned data capacity h and the cleaning time t during the nth cleaning is h n =f(tn), then substitute the number of cleaning times n, the data volume of cleaning h and the time of cleaning t into the calculation formula for calculus summation, that is, the cleaning status of the second unit time:
[0016]
[0017] Then we can find the necessary degree of disk cleaning: m0 = (a1 + a2) × b, that is,
[0018]
[0019] According to the above technical solution, the method for calculating the proportion of subroutines in the cached process that cannot be cleaned by the data interpreted by the code interpretation and analysis program in the Internet of Things is:
[0020] The running code is intercepted every 3 seconds, and the total number of programs b0 in the Internet of Things is calculated based on the code, and the characteristics of each program in the code are further screened, including: calculating the program data capacity through the ratio of the program data capacity in the code to the spatial data capacity in the Internet of Things, capturing the program fragments in the code and comparing them with the distribution form of the second comparison database to obtain the program fragment distribution form, calculating the program logical structure to obtain the program instruction form, judging whether the program carries a virus by comparing other codes carried by the program with the second comparison database, judging whether the program is a macro program based on the program data capacity in the code, judging whether the program is a redundant program based on the distribution form of the program fragments in the code, judging whether the program is a trigger program based on the instruction form of the program in the code, and judging whether the program is a harmful program or a dangerous program based on whether the program in the code carries a virus, and then counting the number of subroutines b1 of the uncleanable cache process in the Internet of Things, and calculating the ratio of the number of subroutines b1 of the uncleanable cache process in the Internet of Things to the total number of subroutines b0 in the Internet of Things. That is, the proportion of subroutines in the process that cannot be cleaned up is obtained.
[0021] According to the above technical solution, the determination of the limited running speed needs to comprehensively consider the actual running speed v0 of the current program, the necessary degree of disk cleaning m0, and the proportion of subroutines of the non-cleanable cache process in the Internet of Things p0, and substitute them into the calculation formula of the limited running speed V to obtain:
[0022] V=v0-(m0-m1)×L0-(p0-p1)×L1, we can further get:
[0023]
[0024] m1 is the preset necessary degree of normal programs, and p1 is the percentage of subroutines of cached processes that cannot be cleaned in the IoT under normal circumstances;
[0025] L0 is the degree of control of the program speed limit by the necessary degree in the unit IoT system, and L1 is the degree of control of the program speed limit by the proportion of the number of subroutines of the cache process that cannot be cleaned in each unit IoT system.
[0026] The limited running speed is compared with the limited running speed of the current system, and the smaller value of the two is the actual limited running speed v1 of the program.
[0027] According to the above technical solution, in the end running time adjustment module, the difference between the estimated time when the program ends running and the specified time is c. If the error |c| is greater than the specified range k, the program end running time needs to be calibrated. The actual limited running speed v2 of the adjusted program is as follows:
[0028] v2=v1+c×L3,
[0029] The L3 is the running speed that needs to be adjusted for the unit size error.
[0030] When the estimated time for the program to finish running is greater than the specified time, c is a positive number;
[0031] When the estimated time for the program to finish running is equal to the specified time, c is 0;
[0032] When the estimated time for the program to finish running is less than the specified time, c is a negative number.
[0033] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: the present invention can classify the operating status of the current system, trigger different disk automatic cleaning strategies in different levels of status, so that the disk of the edge server is in a healthy and available state, reducing the risk of data loss. At the same time, it can decide whether to perform automatic cleaning according to the type of program, and determine the running speed of the program, to prevent code errors caused by running too fast. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0035] Figure 1 It is a schematic diagram of the overall process structure of the present invention;
[0036] Figure 2 It is a schematic diagram of the level division of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] See also Figure 1-2 , the present invention provides a technical solution: a method for automatically cleaning a disk of an IoT edge server, comprising step S0, setting a scheduled task on the IoT edge server, which is triggered every 30 minutes;
[0039] Step S1, divide the system into different levels according to the current disk usage, set the range in advance in the program, and only clean up the files within the range;
[0040] Step S2: Different disk cleanup strategies can be triggered according to different levels, and the strategies are divided into three situations;
[0041] In the above step S2, the three situations are:
[0042] S2-1, Level 1 includes a log cleanup strategy, which retains logs within 7 days;
[0043] S2-2, Level 2 includes a log cleanup strategy, which retains logs within 3 days and cleans up some persistent files and photos, retaining files and photos from the last 2 months;
[0044] S2-3, Level 3 includes the data cleanup strategy for the database, which involves cleaning up the historical retained data in the database table;
[0045] In the above step S2, the specific content of log cleaning is the log of OS service, the log of Linux system, and the disk partition capacity>50%;
[0046] The specific contents of file / image cleanup include unused Docker images, temporarily uploaded and stored files, and disk partition capacity > 60%;
[0047] The specific content of database cleaning is kafka, influxdb, mysql historical data cleaning, disk partition capacity> 80%;
[0048] At the current running speed, the number of times the cache file is reduced per unit time is recorded as a negative number a1, and the number of times the cache file is increased per unit time is recorded as a positive number a2. After each unit time, the number of times the cache file is increased and the number of times the cache file is reduced in that unit time are added together, that is, a1+a2;
[0049] The cleaning status includes: the number of cleaning times n, the cleaned data capacity h and the cleaning time t. The relationship between the cleaned data capacity h and the cleaning time t during the nth cleaning is h n =f(tn), then substitute the number of cleaning times n, the data volume of cleaning h and the time of cleaning t into the calculation formula for calculus summation, that is, the cleaning status of the second unit time:
[0050]
[0051] Then we can find the necessary degree of disk cleaning: m0 = (a1 + a2) × b, that is,
[0052]
[0053] The method for calculating the proportion of subroutines in the process that cannot be cleaned of cache using the data interpreted by the code interpretation and analysis program in the Internet of Things is as follows:
[0054] The running code is intercepted every 3 seconds, and the total number of programs b0 in the Internet of Things is calculated based on the code, and the characteristics of each program in the code are further screened, including: calculating the program data capacity through the ratio of the program data capacity in the code to the spatial data capacity in the Internet of Things, capturing the program fragments in the code and comparing them with the distribution form of the second comparison database to obtain the program fragment distribution form, calculating the program logical structure to obtain the program instruction form, judging whether the program carries a virus by comparing other codes carried by the program with the second comparison database, judging whether the program is a macro program based on the program data capacity in the code, judging whether the program is a redundant program based on the distribution form of the program fragments in the code, judging whether the program is a trigger program based on the instruction form of the program in the code, and judging whether the program is a harmful program or a dangerous program based on whether the program in the code carries a virus, and then counting the number of subroutines b1 of the uncleanable cache process in the Internet of Things, and calculating the ratio of the number of subroutines b1 of the uncleanable cache process in the Internet of Things to the total number of subroutines b0 in the Internet of Things. That is, the proportion of subroutines in the process that cannot be cleaned up is obtained.
[0055] The determination of the running speed limit needs to comprehensively consider the actual running speed v0 of the current program, the necessary degree of disk cleaning m0, and the proportion of subroutines of the uncleanable cache process in the Internet of Things p0. Substituting them into the calculation formula of the running speed limit V, we get:
[0056] V=v0-(m0-m1)×L0-(p0-p1)×L1, we can further get:
[0057]
[0058] m1 is the preset necessary degree of normal programs, and p1 is the percentage of subroutines of cached processes that cannot be cleaned in the IoT under normal circumstances;
[0059] L0 is the degree of control of the program speed limit by the necessary degree in the unit IoT system, and L1 is the degree of control of the program speed limit by the proportion of the number of subroutines of the cache process that cannot be cleaned in each unit IoT system.
[0060] Compare the limited running speed with the current system's limited running speed, and the smaller value between the two is the current actual limited running speed v1 of the program;
[0061] The difference between the estimated time for the program to end and the specified time is c. If the error |c| is greater than the specified range k, the program end time needs to be calibrated. The actual limited running speed v2 of the adjusted program is as follows:
[0062] v2=v1+c×L3,
[0063] The L3 is the running speed that needs to be adjusted for the unit size error.
[0064] When the estimated time for the program to finish running is greater than the specified time, c is a positive number;
[0065] When the estimated time for the program to finish running is equal to the specified time, c is 0;
[0066] When the estimated time for the program to finish running is less than the specified time, c is a negative number;
[0067] The current system operation status can be graded, and different disk automatic cleaning strategies can be triggered at different levels, so that the disk of the edge server is in a healthy and available state, reducing the risk of data loss. At the same time, it can be decided whether to perform automatic cleaning and the running speed of the program according to the type of program to prevent code errors caused by running too fast.
[0068] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0069] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for automatically cleaning disks of an IoT edge server, characterized in that: include: Step S0: Set up a scheduled task on the IoT edge server and trigger it every 30 minutes; Step S1: divide the system into different levels according to the current disk usage rate, set the range in the program in advance, and only clean up the files within the range; the method for calculating the proportion of subroutines of the cache process that cannot be cleaned up by the data interpreted by the code interpretation and analysis program in the Internet of Things is: The running code is intercepted every 3 seconds, and the total number of programs b0 in the Internet of Things is calculated based on the code, and the characteristics of each program in the code are further screened, including: calculating the program data capacity through the ratio of the program data capacity in the code to the spatial data capacity in the Internet of Things, capturing the program fragments in the code and comparing them with the distribution form of the second comparison database to obtain the program fragment distribution form, calculating the program logical structure to obtain the program instruction form, judging whether the program carries a virus by comparing other codes carried by the program with the second comparison database, judging whether the program is a macro program based on the program data capacity in the code, judging whether the program is a redundant program based on the distribution form of the program fragments in the code, judging whether the program is a trigger program based on the instruction form of the program in the code, and judging whether the program is a harmful program or a dangerous program based on whether the program in the code carries a virus, and then counting the number of subroutines b1 of the uncleanable cache process in the Internet of Things, and calculating the ratio of the number of subroutines b1 of the uncleanable cache process in the Internet of Things to the total number of subroutines b0 in the Internet of Things. That is, the proportion of subroutines in the process that cannot be cleaned up is obtained. The determination of the running speed limit needs to comprehensively consider the actual running speed v0 of the current program, the necessary degree of disk cleaning m0, and the proportion of subroutines of the uncleanable cache process in the Internet of Things p0. Substituting them into the calculation formula of the running speed limit V, we get: V=v0-(m0-m1)×L0-(p0-p1)×L1, we can further get: m1 is the preset necessary degree of normal programs, and p1 is the percentage of subroutines of cached processes that cannot be cleaned in the IoT under normal circumstances; L0 is the degree of control of the program speed limit by the necessary degree in the unit IoT system, and L1 is the degree of control of the program speed limit by the proportion of the number of subroutines of the cache process that cannot be cleaned in each unit IoT system. Compare the limited running speed with the current system's limited running speed, and the smaller value between the two is the current actual limited running speed v1 of the program; Step S2: Different disk cleanup strategies can be triggered according to different levels, and the strategies are divided into three situations.
2. According to claim 1, the method for automatically cleaning a disk of an IoT edge server is characterized in that: In the above step S2, the three situations are: S2-1, Level 1 includes a log cleanup strategy, which retains logs within 7 days; S2-2, Level 2 includes a log cleanup strategy, which retains logs within 3 days and cleans up some persistent files and photos, retaining files and photos from the last 2 months; S2-3, Level 3 includes the data cleanup strategy for the database, which involves cleaning up the historical retained data in the database tables.
3. The method for automatically cleaning a disk of an IoT edge server according to claim 2, characterized in that: In the above step S2, the specific content of log cleaning is the log of OS service, the log of Linux system, and the disk partition capacity>50%; The specific contents of file / image cleanup include unused Docker images, temporarily uploaded and stored files, and disk partition capacity > 60%; The specific content of database cleaning is kafka, influxdb, mysql historical data cleaning, and disk partition capacity > 80%.
4. The method for automatically cleaning a disk of an IoT edge server according to claim 3, characterized in that: At the current running speed, the number of times the cache file is reduced per unit time is recorded as a negative number a1, and the number of times the cache file is increased per unit time is recorded as a positive number a2. After each unit time, the number of times the cache file is increased and the number of times the cache file is reduced within the unit time are added together, that is, a1+a2.
5. The method for automatically cleaning a disk of an IoT edge server according to claim 4, characterized in that: The cleaning status includes: the number of cleaning times n, the cleaned data capacity h and the cleaning time t. The relationship between the cleaned data capacity h and the cleaning time t during the nth cleaning is h n =f(tn), then substitute the number of cleaning times n, the data volume of cleaning h and the time of cleaning t into the calculation formula for calculus summation, that is, the cleaning status of the second unit time: Then we can find the necessary degree of disk cleaning: m0 = (a1 + a2) × b, that is, 6. The method for automatically cleaning a disk of an IoT edge server according to claim 1, characterized in that: The difference between the estimated time for the program to end and the specified time is c. If the error |c| is greater than the specified range k, the program end time needs to be calibrated. The actual limited running speed v2 of the adjusted program is as follows: v2=v1+c×L3, The L3 is the running speed that needs to be adjusted for the unit size error. When the estimated time for the program to finish running is greater than the specified time, c is a positive number; When the estimated time for the program to finish running is equal to the specified time, c is 0; When the estimated time for the program to finish running is less than the specified time, c is a negative number.
Citation Information
Patent Citations
Log cleaning method and device based on dynamic log cleaning strategy
CN114238302A