Junk file cleaning method, device, electronic device and storage medium
By fitting the junk file amount prediction function and the automated cleaning mechanism, the problem of the inability to automate the junk file cleaning in the existing technology is solved, and the server's operating efficiency and storage space management are improved.
Patent Information
- Application Number
- CN202111270521.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-10-29
AI Technical Summary
Existing junk file cleaning software cannot automatically clean junk files on the server, especially when the server is busy, resulting in slow cleaning or system lags.
Obtain the amount of junk files at historical time points through sampling, fit the junk file amount prediction function, calculate the predicted amount and predicted time point, determine the cleanup time period when the predicted amount is greater than the threshold, and automatically clean up the garbage when the server load is less than the threshold. document.
It realizes automatic cleaning of junk files, avoids slow cleaning and system freezes when the server is busy, and improves storage space utilization and system performance.
Smart Images

Figure CN114328402B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a junk file cleaning method, device, electronic device and computer-readable storage medium. Background Art
[0002] On a Linux server, the installation and operation of the system and software will generate a large number of junk files. If the junk software is not cleaned up in time, it will take up a lot of storage space, affect system operation, cause system freezes and slow responses, and in severe cases, cause the system to crash.
[0003] Existing junk file cleaning software will display suspicious junk files to users after scanning and screening files on the server. The junk files will only be deleted after the user manually checks the box. These junk files cannot be cleaned automatically. When users choose to clean junk files, the server may be busy with business, and junk files need to be cleaned under the pressure of the server, which will cause slow junk cleaning and even system freezes. Summary of the invention
[0004] The present invention provides a junk file cleaning method, device and computer-readable storage medium, the main purpose of which is to solve the problem of server busyness during junk file cleaning.
[0005] To achieve the above object, the present invention provides a junk file cleaning method, comprising:
[0006] A historical time point is selected by sampling, and the amount of junk files in the server at the historical time point is obtained;
[0007] According to the junk file amount at the historical time point, a junk file amount prediction function is obtained by fitting;
[0008] Performing initial assignment on the parameters in the junk file amount prediction function, calculating the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained;
[0009] The optimal junk file amount prediction function is used to calculate the predicted amount of junk files and the corresponding predicted time point, and when the predicted amount of junk files is greater than a preset file amount threshold, a cleaning time period is determined according to the predicted time point;
[0010] Obtaining average server load data during the cleaning time period;
[0011] When the average load data is greater than or equal to the preset server load threshold, return to the step of using the optimal junk file amount prediction function to calculate the junk file prediction amount and the corresponding prediction time point, and re-determine the cleaning time period;
[0012] When the average load data is less than a preset server load threshold, junk files in the server are automatically cleaned up within the cleaning time period.
[0013] Optionally, the selecting a historical time point by sampling and obtaining the amount of junk files in the server at the historical time point includes:
[0014] Randomly select a preset number of historical time points from a preset time period;
[0015] All junk files in the server within a preset historical time period are obtained, and the amount of junk files at each historical time point is counted according to the time when the junk files are generated and the size of the junk files.
[0016] Optionally, the step of fitting a junk file amount prediction function according to the junk file amount at the historical time point includes:
[0017] Performing standardization processing on the historical time point and the amount of junk files at the historical time point to obtain standardized data;
[0018] The historical time points in the standardized data are taken as independent variables, and the junk file quantity is taken as a dependent variable, and a junk file quantity prediction function is obtained by fitting.
[0019] Optionally, the calculating the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained, comprises:
[0020] The junk file amount prediction function after the assignment is used to calculate the predicted amount of junk files at the historical time point;
[0021] Obtaining the actual amount of junk files at the historical time point, and calculating the loss value between the predicted amount of junk files and the actual amount of junk files using a preset loss function;
[0022] When the loss value is greater than or equal to a preset threshold, the parameters of the junk file amount prediction function are adjusted using a gradient descent method, and the process returns to the step of calculating the predicted amount of junk files at the historical time point using the junk file amount prediction function after the assignment;
[0023] When the loss value is less than a preset threshold, an optimal junk file amount prediction function is obtained.
[0024] Optionally, when the loss value is greater than a preset threshold, adjusting the parameters of the function using a gradient descent method includes:
[0025] Calculating the gradient of the parameters in the junk file amount prediction function;
[0026] Correcting the parameters of the junk file amount prediction function along the gradient direction of the parameters;
[0027] The modified parameters are assigned to the junk file amount prediction function, and the loss value of the junk file amount prediction function after the assignment is calculated using a preset loss function is returned, and the parameters in the junk file amount prediction function are adjusted according to the loss value until an optimal junk file amount prediction function is obtained.
[0028] Optionally, the calculating the loss value between the predicted amount of junk files and the actual amount of junk files by using a preset loss function includes:
[0029] The loss value L(f) is calculated using the following loss function:
[0030]
[0031] Among them, X t is the predicted amount of junk files, w and b are the parameters of the junk file amount prediction function, n is the number of historical time points, y n is the actual amount of junk files.
[0032] Optionally, obtaining average server load data within the cleaning time period includes:
[0033] Obtain historical load data of each node of the server during the cleaning time period;
[0034] The server average load is calculated according to the historical load data of each node to obtain the server average load data.
[0035] In order to solve the above problems, the present invention also provides a junk file cleaning method and device, the device comprising:
[0036] The junk file information acquisition module is used to select a historical time point by sampling and obtain the amount of junk files at the historical time point in the server;
[0037] A function fitting module, used for fitting the junk file amount prediction function according to the junk file amount at the historical time point;
[0038] An optimal junk file amount prediction function generation module is used to perform initial assignment on the parameters in the junk file amount prediction function, calculate the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjust the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained;
[0039] A cleaning time period determination module, used to calculate the predicted amount of junk files and the corresponding predicted time point using the optimal junk file amount prediction function, and when the predicted amount of junk files is greater than a preset file amount threshold, determine the cleaning time period according to the predicted time point;
[0040] A server average load acquisition module, used to obtain the server average load data within the cleaning time period;
[0041] The junk file cleaning module is used to automatically clean up junk files in the server within the cleaning time period when the average load data is less than a preset server load threshold.
[0042] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0043] at least one processor; and,
[0044] a memory communicatively connected to the at least one processor; wherein,
[0045] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the junk file cleaning method described above.
[0046] In order to solve the above problem, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned junk file cleaning method.
[0047] The embodiment of the present invention uses the amount of junk files at historical time points to fit multiple junk file prediction functions with different parameters, calculates the loss values of the multiple junk file prediction functions, and selects the optimal junk file prediction function from the multiple junk file prediction functions according to the loss value to generate a junk file amount prediction model, which can accurately predict the amount of junk files; the junk file prediction amount and the prediction time point are obtained through the optimal junk file amount prediction function, when the junk file prediction amount reaches a preset threshold, the cleaning time period is determined through the prediction time point, the average server load data within the cleaning time period is obtained, and if the average load data is less than the preset threshold, the junk files are automatically cleaned within the cleaning time period. Therefore, the junk file cleaning method, device, electronic device and computer-readable storage medium proposed in the present invention can solve the problem of busy servers during junk file cleaning. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of a flow chart of a junk file cleaning method provided by an embodiment of the present invention;
[0049] Figure 2 A schematic diagram of a flow chart of generating an optimal junk file amount prediction function provided by an embodiment of the present invention;
[0050] Figure 3 A functional module diagram of a junk file cleaning method and device provided by an embodiment of the present invention;
[0051] Figure 4 A schematic diagram of the structure of an electronic device for implementing the junk file cleaning method provided by an embodiment of the present invention.
[0052] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0054] The embodiment of the present application provides a method for cleaning up junk files. The execution subject of the junk file cleaning method includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the junk file cleaning method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.
[0055] Reference Figure 1 FIG. 1 is a flow chart of a junk file cleaning method provided by an embodiment of the present invention. In this embodiment, the junk file cleaning method includes:
[0056] S1. Select a historical time point by sampling, and obtain the amount of junk files in the server at the historical time point;
[0057] In an embodiment of the present invention, normal business files are stored in the server, including files saved by users, network cache files, application cache files, etc. These files may contain junk files. The embodiment of the present invention adopts a sampling method to obtain the amount of junk files in the server at different time points.
[0058] In detail, the method of selecting a historical time point by sampling and obtaining the amount of junk files in the server at the historical time point includes:
[0059] Step A: randomly select a preset number of historical time points from a preset time period;
[0060] For example, the embodiment of the present invention can randomly select 6 time points every day from the past month, such as 12:00 am, 6:00 am, 12:00 noon, 3:00 pm, 6:00 pm, 10:00 pm, etc.
[0061] Step B: Obtain all junk files in the server within a preset historical time period, and count the amount of junk files at each historical time point according to the time when the junk files were generated and the size of the junk files.
[0062] For example, an embodiment of the present invention obtains all junk files in the server within the past 24 hours, and obtains the generation time of each junk file and the file size of each junk file. If a junk file is generated at 4 pm and the file size is 100M, then the amount of junk files at 6 pm is increased by 100M; if a junk file is generated at 7 pm and the file size is 50M, then the amount of junk files at 10 pm is increased by 50M, and so on.
[0063] S2. fitting a junk file amount prediction function according to the junk file amount at the historical time point;
[0064] In the embodiment of the present invention, the junk file amount at the historical time point is fitted to obtain a junk file amount prediction function. According to the different fitting degrees of the junk file historical data, the embodiment of the present invention can obtain multiple junk file amount prediction functions with different parameters.
[0065] In detail, the step of fitting the junk file amount prediction function according to the junk file amount at the historical time point includes:
[0066] Performing standardization processing on the historical time point and the amount of junk files at the historical time point to obtain standardized data;
[0067] The historical time points in the standardized data are taken as independent variables, and the junk file quantity is taken as a dependent variable, and a junk file quantity prediction function is obtained by fitting.
[0068] In the embodiment of the present invention, the standardization process is to scale down the data so that the data is limited to a small specific range, remove the unit restriction of the data, and convert the data into dimensionless pure numerical values, which can accelerate the convergence speed of the data and improve the calculation efficiency.
[0069] Specifically, the embodiment of the present invention may use the following formula to perform standardization processing on the historical time point and the amount of junk files at the historical time point:
[0070]
[0071] Where X is the original data value, X max is the maximum value in the data, X min is the minimum value in the data, X nom is the data value after standardization.
[0072] Exemplarily, the junk file amount prediction function may be:
[0073] y=w*X t +b
[0074] Where y is the amount of junk files, X tis a time point, w and b are unknown parameters and can be any values.
[0075] S3, performing initial assignment on the parameters in the junk file amount prediction function, calculating the loss value of the junk file amount prediction function after the assignment, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained;
[0076] The embodiment of the present invention may assign default initial values to the parameters in the junk file amount prediction function.
[0077] Further, see Figure 2 As shown, the loss value of the junk file amount prediction function after the assignment is calculated using a preset loss function, and the parameters in the junk file amount prediction function are adjusted according to the loss value until the optimal junk file amount prediction function is obtained, including:
[0078] S31, using the assigned junk file amount prediction function to calculate the predicted amount of junk files at the historical time point;
[0079] S32, obtaining the actual amount of junk files at the historical time point, and using a preset loss function to calculate a loss value between the predicted amount of junk files and the actual amount of junk files, and determining whether the loss value is less than a preset threshold;
[0080] S33, when the loss value is greater than or equal to a preset threshold, adjusting the parameters of the junk file amount prediction function using a gradient descent method, and returning to the above step S31;
[0081] S34. When the loss value is less than a preset threshold, an optimal junk file amount prediction function is obtained.
[0082] For example, the junk file prediction function calculates that the junk file amount in the previous hour is 2.6GB, while the actual junk file amount in the previous hour is 2.53GB. The junk file amount error value is 0.07GB. By summarizing all the loss values obtained in the embodiment of the present invention, the loss value between the junk file prediction amount and the actual junk file amount can be obtained.
[0083] Furthermore, the calculating the loss value between the predicted amount of junk files and the actual amount of junk files by using a preset loss function includes:
[0084] The loss value L(f) is calculated using the following loss function:
[0085]
[0086] Among them, X tis the predicted amount of junk files, w and b are the parameters of the junk file amount prediction function, n is the number of historical time points, y n is the actual amount of junk files.
[0087] In one embodiment of the present invention, when the loss value is greater than a preset threshold, the error between the junk file amount prediction function and the actual value of the junk file is relatively large, and the parameters in the junk file amount prediction function need to be adjusted until the loss value is less than the preset threshold, and the parameters at this time are assigned to the junk file amount prediction function as the optimal parameters to obtain the optimal junk file amount prediction function.
[0088] In detail, the optimal parameters in the embodiment of the present invention are:
[0089]
[0090] In detail, when the loss value is greater than a preset threshold, adjusting the parameters of the function using the gradient descent method includes:
[0091] Calculating the gradient of the parameters in the junk file prediction function;
[0092] Correcting the parameters of the junk file amount prediction function along the gradient direction of the parameters;
[0093] The modified parameters are assigned to the junk file amount prediction function.
[0094] Furthermore, the embodiment of the present invention uses the following formula to calculate the gradient of the parameters in the junk file prediction function:
[0095]
[0096] Furthermore, the embodiment of the present invention uses the following formula to correct the parameters of the junk file amount prediction function:
[0097]
[0098]
[0099] …
[0100]
[0101] Wherein, η is the span of each modification of the parameter, which can be a preset value, that is, the size of each update of the junk file prediction function parameter is and
[0102] S4, using the junk file amount prediction model to calculate the predicted amount of junk files and the predicted time point, and when the predicted amount of junk files is greater than a preset file amount threshold, determining a cleaning time period according to the predicted time point;
[0103] In an embodiment of the present invention, if the predicted amount of junk files is greater than a preset junk file amount threshold, that is, the amount of junk files has accumulated to a certain order of magnitude, it is necessary to clean up the junk files in a timely manner to avoid system freezes, slow server operation, or even damage to the host hardware due to the accumulation of junk files.
[0104] For example, the junk file amount prediction model calculates that the amount of junk files will accumulate to 10GB after 14:18 on August 20, 2021, then 14:18 on August 20, 2021 or a preset time period before and after, such as 30 minutes before and after, that is, the time period from 13:48 on August 20, 2021 to 4:48 on August 20, 2021 is determined as the junk file cleaning time point.
[0105] S5. Obtain average server load data within the cleaning time period, and determine whether the average server load data is greater than or equal to a preset server load threshold;
[0106] In the embodiment of the present invention, the system load includes network traffic, memory usage, hard disk load, CPU load, etc., and the average load is used to determine whether the server is in a busy state. If the system load is too large, it may affect system performance, cause system freezes, and affect system output efficiency.
[0107] In detail, obtaining the average server load data within the cleaning time period includes:
[0108] Obtain historical load data of each node of the server during the cleaning time period;
[0109] Calculate the average server load according to the historical load data of each node to obtain the average server load data.
[0110] When the average load data is greater than or equal to the preset server load threshold, return to S4.
[0111] By judging whether the server is busy through the server average load data, the efficiency of junk file cleaning can be improved and system freezes caused by cleaning junk files can be avoided.
[0112] In an embodiment of the present invention, when the average load data is greater than or equal to a preset server load threshold, the server is busy during the cleaning time period, and cleaning up junk files may cause system freezes, and in severe cases may damage the server hardware. The process returns to the step of obtaining the average load data of the server during the cleaning time period, and the cleaning time period is re-determined. When the average load data of the server is less than the preset load threshold, the junk files are cleaned up again.
[0113] When the average load data is less than a preset server load threshold, S6, automatically cleaning junk files in the server within the cleaning time period.
[0114] In the embodiment of the present invention, if the system average load data is less than a preset threshold, the server is in a relatively idle state during the cleaning time period, and junk files can be cleaned up.
[0115] like Figure 3 , which is a functional module diagram of a junk file cleaning method and device provided by an embodiment of the present invention.
[0116] The junk file cleaning method device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the junk file cleaning method device 100 can include a junk file information acquisition module 101, a function fitting module 102, an optimal junk file amount prediction function generation module 103, a cleaning time period determination module 104, a server average load acquisition module 105 and a junk file cleaning module 106. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0117] In this embodiment, the functions of each module / unit are as follows:
[0118] The junk file information acquisition module 101 is used to select a historical time point by sampling and obtain the amount of junk files at the historical time point in the server;
[0119] The function fitting module 102 is used to fit the junk file amount prediction function according to the junk file amount at the historical time point;
[0120] The optimal junk file amount prediction function generation module 103 is used to perform initial assignment of parameters in the junk file amount prediction function, calculate the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjust the parameters in the junk file amount prediction function according to the loss value until the optimal junk file amount prediction function is obtained;
[0121] The cleaning time period determination module 104 is used to calculate the predicted amount of junk files and the corresponding predicted time point using the optimal junk file amount prediction function, and when the predicted amount of junk files is greater than a preset file amount threshold, determine the cleaning time period according to the predicted time point;
[0122] The server average load acquisition module 105 is used to obtain the server average load data within the cleaning time period.
[0123] The junk file cleaning module 106 is used to automatically clean up junk files in the server within the cleaning time period when the average load data is less than a preset server load threshold.
[0124] In detail, each module described in the junk file cleaning method device 100 of the embodiment of the present invention is used in the same manner as described above. Figure 1 to Figure 2 The junk file cleaning method described in the invention has the same technical means and can produce the same technical effect, so I will not go into details here.
[0125] like Figure 4 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing a junk file cleaning method provided by an embodiment of the present invention.
[0126] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a junk file cleaning method program.
[0127] In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing a junk file cleaning method program, etc.), and calls data stored in the memory 11 to execute various functions of the electronic device and process data.
[0128] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. The memory 11 may be an internal storage unit of an electronic device in some embodiments, such as a mobile hard disk of the electronic device. The memory 11 may also be an external storage device of an electronic device in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device, such as the code of a junk file cleaning method program, but may also be used to temporarily store data that has been output or is to be output.
[0129] The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0130] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0131] Figure 4 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 4The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0132] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0133] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0134] The junk file cleaning method program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0135] A historical time point is selected by sampling, and the amount of junk files in the server at the historical time point is obtained;
[0136] According to the junk file amount at the historical time point, a junk file amount prediction function is obtained by fitting;
[0137] Performing initial assignment on the parameters in the junk file amount prediction function, calculating the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained;
[0138] The optimal junk file amount prediction function is used to calculate the predicted amount of junk files and the corresponding predicted time point, and when the predicted amount of junk files is greater than a preset file amount threshold, a cleaning time period is determined according to the predicted time point;
[0139] Obtaining average server load data during the cleaning time period;
[0140] When the average load data is greater than or equal to the preset server load threshold, return to the step of using the optimal junk file amount prediction function to calculate the junk file prediction amount and the corresponding prediction time point, and re-determine the cleaning time period;
[0141] When the average load data is less than a preset server load threshold, junk files in the server are automatically cleaned up within the cleaning time period.
[0142] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.
[0143] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0144] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0145] A historical time point is selected by sampling, and the amount of junk files in the server at the historical time point is obtained;
[0146] According to the junk file amount at the historical time point, a junk file amount prediction function is obtained by fitting;
[0147] Performing initial assignment on the parameters in the junk file amount prediction function, calculating the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained;
[0148] The optimal junk file amount prediction function is used to calculate the predicted amount of junk files and the corresponding predicted time point, and when the predicted amount of junk files is greater than a preset file amount threshold, a cleaning time period is determined according to the predicted time point;
[0149] Obtaining average server load data during the cleaning time period;
[0150] When the average load data is greater than or equal to the preset server load threshold, return to the step of using the optimal junk file amount prediction function to calculate the junk file prediction amount and the corresponding prediction time point, and re-determine the cleaning time period;
[0151] When the average load data is less than a preset server load threshold, junk files in the server are automatically cleaned up within the cleaning time period.
[0152] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0153] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0154] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0155] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0156] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0157] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0158] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0159] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A junk file cleaning method, characterized in that: The method comprises: A historical time point is selected by sampling, and the amount of junk files in the server at the historical time point is obtained; According to the junk file amount at the historical time point, a junk file amount prediction function is obtained by fitting; Performing initial assignment on the parameters in the junk file amount prediction function, calculating the loss value of the junk file amount prediction function after the assignment, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained; The optimal junk file amount prediction function is used to calculate the predicted amount of junk files and the corresponding predicted time point, and when the predicted amount of junk files is greater than a preset file amount threshold, a cleaning time period is determined according to the predicted time point; Obtaining average server load data during the cleaning time period; When the average load data is greater than or equal to the preset server load threshold, return to the step of using the optimal junk file amount prediction function to calculate the junk file prediction amount and the corresponding prediction time point, and re-determine the cleaning time period; When the average load data is less than a preset server load threshold, junk files in the server are automatically cleaned up within the cleaning time period.
2. The junk file cleaning method according to claim 1, characterized in that: The method of selecting a historical time point by sampling and obtaining the amount of junk files in the server at the historical time point includes: Randomly select a preset number of historical time points from a preset time period; All junk files in the server within a preset historical time period are obtained, and the amount of junk files at each historical time point is counted according to the time when the junk files are generated and the size of the junk files.
3. The junk file cleaning method according to claim 1, characterized in that: The step of fitting the junk file amount prediction function according to the junk file amount at the historical time point includes: Performing standardization processing on the historical time point and the amount of junk files at the historical time point to obtain standardized data; The historical time points in the standardized data are taken as independent variables, and the junk file quantity is taken as a dependent variable, and a junk file quantity prediction function is obtained by fitting.
4. The junk file cleaning method according to claim 1, characterized in that: The calculating the loss value of the junk file amount prediction function after the assignment, and adjusting the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained, comprises: The junk file amount prediction function after the assignment is used to calculate the predicted amount of junk files at the historical time point; Obtaining the actual amount of junk files at the historical time point, and calculating the loss value between the predicted amount of junk files and the actual amount of junk files using a preset loss function; When the loss value is greater than or equal to a preset threshold, the parameters of the junk file amount prediction function are adjusted using a gradient descent method, and the process returns to the step of calculating the predicted amount of junk files at the historical time point using the junk file amount prediction function after the assignment; When the loss value is less than a preset threshold, an optimal junk file amount prediction function is obtained.
5. The junk file cleaning method according to claim 4, characterized in that: When the loss value is greater than or equal to a preset threshold, adjusting the parameters of the junk file amount prediction function by using a gradient descent method includes: Calculating the gradient of the parameters in the junk file amount prediction function; Correcting the parameters of the junk file amount prediction function along the gradient direction of the parameters; The modified parameters are assigned to the junk file amount prediction function.
6. The junk file cleaning method according to any one of claims 1 to 5, characterized in that: The obtaining of the average server load data within the cleaning time period includes: Obtain historical load data of each node of the server during the cleaning time period; The server average load is calculated according to the historical load data of each node to obtain the server average load data.
7. A junk file cleaning device, characterized in that: The device comprises: The junk file information acquisition module is used to select a historical time point by sampling and obtain the amount of junk files at the historical time point in the server; A function fitting module, used for fitting the junk file amount prediction function according to the junk file amount at the historical time point; An optimal junk file amount prediction function generation module is used to perform initial assignment on the parameters in the junk file amount prediction function, calculate the loss value of the junk file amount prediction function after the assignment using a preset loss function, and adjust the parameters in the junk file amount prediction function according to the loss value until an optimal junk file amount prediction function is obtained; A cleaning time period determination module, used to calculate the predicted amount of junk files and the corresponding predicted time point using the optimal junk file amount prediction function, and when the predicted amount of junk files is greater than a preset file amount threshold, determine the cleaning time period according to the predicted time point; A server average load acquisition module, used to obtain the server average load data within the cleaning time period; The junk file cleaning module is used to automatically clean up junk files in the server within the cleaning time period when the average load data is less than a preset server load threshold.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the junk file cleaning method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the junk file cleaning method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Junk file cleaning method, intelligent terminal and computer readable storage medium
CN108021630A
Picture file cleaning method and device
CN111399778A
