Method and system for realizing real-time synchronization of dynamic files based on Linux

Log files are generated through Java programs and Linux commands are generated dynamically using real-time synchronization scripts for file synchronization. Combined with consistency check scripts and connection number control, it solves the problem of delay, omissions and connection number control of real-time synchronization of dynamic files in Linux systems, and improves data consistency and system stability.

CN119807153APending Publication Date: 2025-04-11CHINA CITIC BANK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411774410.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

The prior art has synchronization delays or omissions when dynamic files are synchronized in Linux systems, requiring complex real-time monitoring scripts, and failing to effectively control the number of connections in high concurrent synchronization operations, affecting synchronization efficiency and system stability.

Method used

Java programs are used to generate log files to record file change information, listen to log files through real-time synchronization scripts, dynamically generate and execute Linux commands to synchronize files, check and create target file paths, record synchronization results, compare log files and synchronization results log files through consistency check scripts, resynchronize incorrect data, and preset the maximum number of connections threshold to control the number of connections.

Benefits of technology

Reduce the time of real-time synchronization of data, avoid complex real-time monitoring scripts, ensure the accuracy and consistency of synchronized files, and improve the data credibility of Linux systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807153A_ABST
    Figure CN119807153A_ABST
Patent Text Reader

Abstract

The invention relates to a method and a system for realizing real-time synchronization of dynamic files based on Linux, and the method comprises the following steps: recording real-time change of a file system by using a Java program to generate a log file, monitoring the log file by using a real-time synchronization script, and dynamically generating and executing a Linux command according to information in a log to synchronize the file. Checking and creating a target file path, executing a synchronization operation in a background, recording a synchronization result as a synchronization result log file, comparing the log file with the synchronization result log file through a consistency checking script, and re-synchronizing data with wrong data consistency according to a comparison result. Therefore, the technical scheme is adopted. According to the technical scheme disclosed by the invention, the real-time data synchronization time can be shortened, real-time monitoring can be carried out without a complicated real-time monitoring script, and the connection number can be limited, so that the accuracy and consistency of the synchronization file are ensured, and the data credibility of the Linux system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer file synchronization, and in particular to a method and system for realizing real-time synchronization of dynamic files based on Linux. The method realizes efficient synchronization of a large number of dynamically changing files through automated logging, monitoring, command generation, execution and consistency checking, and is suitable for file transfer scenarios requiring high data consistency and real-time performance. Background Art

[0002] With the development of computer technology, real-time file synchronization technology is used in computer information technology to ensure data consistency and high availability. By copying data from one location to another, data backup or mirroring is achieved to ensure that the copied or backed-up data can be used immediately when data failure occurs.

[0003] In Linux systems, real-time data synchronization is an important task, especially for application scenarios that need to maintain data consistency in multiple directories or servers. For example, in a file transfer system, files in multiple Linux servers are shared using NAS disks. In a scenario where a NAS disk is switched from old to new, in order to reduce the impact on production business transactions, the files on the two NAS disks need to be synchronized, and real-time file synchronization needs to be achieved to ensure the immediacy and accuracy of the files in the two NASs, that is, when the old NAS file changes, the new NAS file needs to change in real time. In the prior art, Linux systems usually use mirror backup tools such as rsync. Although they can achieve file synchronization to a certain extent, when faced with a large number of dynamically changing files, there are often problems with synchronization delays or omissions. At the same time, real-time monitoring is required for the real-time changing file system during synchronization. File system event monitoring tools (such as inotify) and script programming are usually used for real-time response, but these methods usually require complex script writing and maintenance, and performance and stability are difficult to guarantee when dealing with large-scale file systems.

[0004] In addition, controlling the number of connections during synchronization is also a key issue. In high-concurrency synchronization operations, if there is no appropriate limit on the number of connections, system resources may be exhausted, thus affecting synchronization efficiency and system stability.

[0005] It can be seen that the existing technology for real-time synchronization of dynamic files still has problems such as long data synchronization time, the need for complex real-time monitoring scripts, no appropriate connection number limit, and inability to ensure the accuracy and consistency of synchronized files, which reduces the data credibility of the Linux system. Therefore, it has become an urgent problem to be solved in the current real-time synchronization of dynamic files in Linux systems. Summary of the invention

[0006] In order to solve the deficiencies of the prior art, the present invention proposes a method for realizing real-time synchronization of dynamic files based on Linux.

[0007] To achieve the above objectives, the technical solutions adopted by the present invention include:

[0008] A method for realizing real-time synchronization of dynamic files based on Linux, characterized by comprising:

[0009] S1. Generate a log file using a Java program, where the log file is used to record file change information;

[0010] S2. Monitor the log file through a real-time synchronization script, obtain operation type information according to the log file information, and generate corresponding Linux commands according to the operation type information;

[0011] S3. Check whether the target file path exists. If not, create it automatically and grant permissions to the directory according to the preset permissions.

[0012] S4. Execute the Linux command in the background to perform file synchronization, and record the operation result in a synchronization result log file, where the synchronization result log file is used to check file consistency;

[0013] S5. Compare the log file and the synchronization result log file using a consistency check script, and resynchronize the data with incorrect data consistency according to the comparison result.

[0014] Furthermore, resynchronizing the data with incorrect data consistency according to the comparison result in step S5 further includes:

[0015] If the comparison result shows that there is an unsynchronized file, the unsynchronized file is found by traversing the log file, and the unsynchronized file is resynchronized.

[0016] Furthermore, resynchronizing the unsynchronized files further includes:

[0017] Determine the source file path and the target file path of the unsynchronized file;

[0018] Execute the Linux command to copy the unsynchronized file from the source path to the target path;

[0019] The operation result is synchronized to the synchronization result log file.

[0020] Furthermore, resynchronizing the data with incorrect data consistency according to the comparison result in step S5 further includes:

[0021] If the comparison result shows that there is a synchronization error file, the synchronization result log file is searched to find the synchronization error file, and the synchronization error file is resynchronized.

[0022] Furthermore, in step S1, using a Java program to generate a log file further includes:

[0023] The real-time change events in the file system are captured, the real-time change events are converted into log entries, and the log file is generated according to the log entries.

[0024] Furthermore, the step S4 further includes:

[0025] A maximum connection number threshold is preset, and file synchronization is performed according to the Linux command. When the number of connections for simultaneously synchronizing files exceeds the preset maximum connection number threshold, new file synchronization operations are queued until the current number of connections is reduced below the threshold due to completion of the synchronization operation.

[0026] Further, in step S3, checking whether the target file path exists, and automatically creating it if it does not exist further includes:

[0027] According to the hierarchical structure of the file path to be synchronized, the same hierarchical structure is created in the target file path accordingly.

[0028] In addition, the present invention also relates to a system for implementing real-time synchronization of dynamic files based on Linux, which is characterized by comprising:

[0029] A log file generation module is used to generate a log file using a Java program, wherein the log file is used to record file change information;

[0030] A log file monitoring module, used to obtain operation type information according to the log file information, and generate corresponding Linux commands according to the operation type information;

[0031] The path check module is used to check whether the target file path exists. If it does not exist, it will be automatically created and the directory will be authorized according to the preset permissions.

[0032] A file synchronization module is used to execute the Linux command in the background to synchronize files and record the operation results in a synchronization result log file, where the synchronization result log file is used to check file consistency;

[0033] The consistency comparison module is used to compare the log file and the synchronization result log file through a consistency check script, and resynchronize the data with incorrect data consistency according to the comparison result.

[0034] In addition, the present invention also relates to an electronic device, characterized in that it comprises a processor and a memory;

[0035] The memory is used to store operation instructions;

[0036] The processor is used to execute the above method by calling the operation instruction.

[0037] In addition, the present invention also relates to a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and the computer program implements the above method when executed by a processor.

[0038] The solution provided by the present application is adopted, and a log file is generated by using a Java program to record the real-time changes of the file system, and a real-time synchronization script is used to monitor the log file, and a Linux command is dynamically generated and executed according to the information in the log to synchronize the file, check and create the target file path, perform synchronization operations in the background, and record the synchronization results as a synchronization result log file. The log file and the synchronization result log file are compared by a consistency check script, and the data with incorrect data consistency is resynchronized according to the comparison results, and the maximum connection number threshold is preset. When the number of connections of the files synchronized at the same time exceeds the preset maximum connection number threshold, the new file synchronization operation is queued for waiting. Therefore, the above technical solution can reduce the time of real-time synchronization of data, and can perform real-time monitoring without complex real-time monitoring scripts, and can limit the number of connections, thereby ensuring the accuracy and consistency of the synchronization files and other issues, and improving the data credibility of the Linux system. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A flowchart of a method for implementing real-time synchronization of dynamic files based on Linux provided in an embodiment of the present application;

[0040] Figure 2 A schematic diagram of a structure of a dynamic file real-time synchronization system based on Linux provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present invention.

[0043] Those skilled in the art can understand that, unless otherwise stated, the singular forms "one", "an", "said" and "the" used herein may also include plural forms, and the "first", "second", etc., are only used to distinguish and define objects for the purpose of introducing the scheme clearly, and do not limit the objects themselves. Of course, the objects defined by "first" and "second" may be the same terminal, device, user, etc., or the same type of terminal, device and user. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0044] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0045] In order to more clearly introduce the technical solution of the present application, some concepts, terms or devices that may be involved in the following embodiments are introduced below to help understand the dynamic file real-time synchronization solution disclosed in the present application:

[0046] rsync: full name remote synchronize, is a remote data synchronization tool under Linux / Unix. It can quickly synchronize files and directories between multiple hosts through LAN / WAN, and properly use the rsync algorithm (differential encoding) to synchronize only changed files and compress data to reduce data transmission. rsync is an open source, fast, multi-functional, and excellent tool for full and incremental (differential backup) local or remote data synchronization backup.

[0047] inotify: inotify is a Linux kernel feature that can monitor changes in information in the synchronization data server directory. It adopts an asynchronous file system event monitoring mechanism and an event-driven mechanism, without the need to obtain events through polling mechanisms such as cron. The Linux kernel has supported inotify since 2.6.13. Through inotify, you can monitor various events such as adding, deleting, modifying, and moving in the file system. The asynchronous feature of inotify can significantly reduce the use of system resources because it does not need to check the file status regularly.

[0048] In the existing file transfer system, once it involves complex multi-level directories, a large number of sub-directories, and different permissions, owners, and groups of directories and files, a huge amount of files, and a large number of dynamic changes in directories and files, the open source rsync+inotify migration tool is used for real-time synchronization, which is time-consuming and data inconsistent, and cannot meet the NAS switching downtime window requirements and file accuracy requirements of the file transfer system production environment.

[0049] therefore Figure 1 The flowchart of the method for implementing real-time synchronization of dynamic files based on Linux provided by the embodiment of the present application is shown, which specifically includes:

[0050] S1. Generate a log file A.log using a Java program. The log file A.log is used to record file change information.

[0051] The log includes the time of file change, the source file path to be synchronized, the source file name, the target file path, the target file name, the operation type, etc. The operation types mainly include file copying, file deletion, file moving, etc. In addition to adding files, there are also scenarios of file deletion and moving files from one directory to another. By capturing real-time change events in the file system, converting the real-time change events into log entries, and generating the log file based on the log entries, any changes in the file system can be captured instantly, and each file change event can be recorded in detail, which can provide a complete file operation history to improve the accuracy of synchronization operations.

[0052] S2. Monitor the log file A.log through a real-time synchronization script, read the log line by line, read the operation type parameter for each line of log information according to the corresponding parameters of the log format, and perform corresponding Linux command splicing according to the operation type, such as cp, rm, mv, etc., to splice into a Linux executable command, such as cp / A / B / C / a.txt / A1 / B / C / a.txt;

[0053] Among them, by real-time monitoring and processing of log files, it is possible to quickly respond to changes in log files, reducing the need for polling or scheduled tasks, thereby improving the efficiency of synchronization operations and ensuring that file synchronization operations can be executed in a timely manner to meet real-time synchronization requirements.

[0054] S3. Check whether the target file path exists. If not, create it automatically and grant permissions to the directory according to the preset permissions.

[0055] Among them, according to the hierarchical structure of the file path to be synchronized, the same hierarchical structure is created in the target file path accordingly, which can ensure the execution of Linux commands and avoid the loss of synchronized files.

[0056] S4. Execute the Linux command in the background to synchronize files, and record the operation results in the synchronization result log file B.log, where the synchronization result log file B.log is used to check file consistency;

[0057] Among them, when synchronizing files, a maximum connection number threshold is preset. The connection number of the first file operation command is 0. For each additional file operation command, the connection number is increased by one. When the number of connections of simultaneously synchronized files exceeds the preset maximum connection number threshold, the new file synchronization operation is queued until the current connection number is reduced below the threshold due to the completion of the synchronization operation.

[0058] S5. Compare the log file and the synchronization result log file using a consistency check script, and resynchronize the data with incorrect data consistency according to the comparison result.

[0059] If the comparison result shows that there is an unsynchronized file, the unsynchronized file is found by traversing the log file, and the source file path and the target file path of the unsynchronized file are determined; the Linux command is executed to copy the unsynchronized file from the source path to the target path; and the operation result is synchronized to the synchronization result log file;

[0060] If the comparison result shows that there is a synchronization error file, the synchronization result log file B.log is searched to find the synchronization error file, and the synchronization error file is resynchronized.

[0061] By comparing the log files and the synchronization result log files through the consistency check script and processing the unsynchronized or synchronized error files according to the comparison results, it can ensure that all files are synchronized as expected, thereby enhancing the reliability and integrity of the data and automating error detection and recovery.

[0062] The above scheme is adopted, by using a Java program to generate a log file to record the real-time changes of the file system, using a real-time synchronization script to monitor the log file, and dynamically generating and executing Linux commands according to the information in the log to synchronize files, checking and creating the target file path, performing synchronization operations in the background, recording the synchronization results as synchronization result log files, and comparing the log file and the synchronization result log file through a consistency check script, resynchronizing the data with incorrect data consistency according to the comparison results, and presetting the maximum connection number threshold. When the number of connections of the files synchronized at the same time exceeds the preset maximum connection number threshold, the new file synchronization operation is queued for waiting. It can reduce the time of real-time synchronization of data, and can perform real-time monitoring without complex real-time monitoring scripts, and can limit the number of connections, thereby ensuring the accuracy and consistency of the synchronized files and other issues, and improving the data credibility of the Linux system.

[0063] based on Figure 1 The method for implementing dynamic file real-time synchronization based on Linux is shown in the figure. On the other hand, it also relates to a system for implementing dynamic file real-time synchronization based on Linux, and its structure is as follows Figure 2 As shown, including:

[0064] A log file generation module 201 is used to generate a log file using a Java program, wherein the log file is used to record file change information;

[0065] The log file monitoring module 202 is used to obtain the operation type information according to the log file information, and generate the corresponding Linux command according to the operation type information;

[0066] Path checking module 203, used to check whether the target file path exists, automatically create it if it does not exist, and grant directory permissions according to preset permissions;

[0067] The file synchronization module 204 is used to execute the Linux command in the background to perform file synchronization and record the operation results in a synchronization result log file, and the synchronization result log file is used to check file consistency;

[0068] The consistency comparison module 205 is used to compare the log file and the synchronization result log file through a consistency check script, and resynchronize the data with incorrect data consistency according to the comparison result.

[0069] Furthermore, the consistency comparison module 205 is also used for:

[0070] If the comparison result shows that there is an unsynchronized file, the unsynchronized file is found by traversing the log file, and the source file path and target file path of the unsynchronized file are determined; the Linux command is executed to copy the unsynchronized file from the source path to the target path; and the operation result is synchronized to the synchronization result log file.

[0071] If the comparison result shows that there is a synchronization error file, the synchronization result log file is searched to find the synchronization error file, and the synchronization error file is resynchronized.

[0072] Furthermore, the log file generating module 201 is also used for:

[0073] The real-time change events in the file system are captured, the real-time change events are converted into log entries, and the log file is generated according to the log entries.

[0074] Furthermore, the file synchronization module 204 is also used for:

[0075] A maximum connection number threshold is preset, and file synchronization is performed according to the Linux command. When the number of connections for simultaneously synchronizing files exceeds the preset maximum connection number threshold, new file synchronization operations are queued until the current number of connections is reduced below the threshold due to completion of the synchronization operation.

[0076] Furthermore, the path checking module 203 is also used for:

[0077] According to the hierarchical structure of the file path to be synchronized, the same hierarchical structure is created in the target file path accordingly.

[0078] An embodiment of the present invention further provides an electronic device for executing the above method, as an implementation device of the method, comprising a processor and a memory;

[0079] A memory, used for storing operation instructions;

[0080] The processor is used to execute the method for implementing real-time synchronization of dynamic files based on Linux provided in any embodiment of the present application by calling an operation instruction.

[0081] As an example, Figure 3 A schematic diagram of the structure of an electronic device applicable to an embodiment of the present application is shown, and the electronic device 300 includes: a processor 301 and a memory 303. The processor 301 and the memory 303 are connected, such as through a bus 302. Optionally, the electronic device 300 may also include a transceiver 304. It should be noted that in actual applications, the transceiver 304 is not limited to one. It is understandable that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the specific structure of the electronic device 300. In other embodiments of the present application, the electronic device 300 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware. Optionally, the electronic device may also include a display screen 305 for displaying images, or receiving user operation instructions when necessary.

[0082] The processor 301 is applied in the embodiment of the present application to implement the method shown in the above method embodiment. The transceiver 304 may include a receiver and a transmitter. The transceiver 304 is applied in the embodiment of the present application to implement the function of the electronic device of the embodiment of the present application communicating with other devices when executed.

[0083] Processor 301 may be a CPU (Central Processing Unit), a general purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 301 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0084] The processor 301 may also include one or more processing units, for example, the processor 301 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processor (NPU). Different processing units may be independent devices or integrated into one or more processors. Among them, the controller may be the nerve center and command center of the electronic device 300. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. A memory may also be provided in the processor 301 for storing instructions and data. In some embodiments, the memory in the processor 301 is a high-speed cache memory. The memory may store instructions or data that the processor 301 has just used or circulated. If the processor 301 needs to use the instruction or data again, it may be directly called from the memory. Repeated access is avoided, the waiting time of the processor 301 is reduced, and the efficiency of the system is improved.

[0085] The processor 301 can run the method for implementing dynamic file real-time synchronization based on Linux provided in the embodiment of the present application, so as to reduce the complexity of user operations, improve the intelligence of terminal devices, and enhance the user experience. The processor 301 can include different devices. For example, when the CPU and GPU are integrated, the CPU and GPU can cooperate to execute the method for implementing dynamic file real-time synchronization based on Linux provided in the embodiment of the present application, with part of the algorithm executed by the CPU and the other part of the algorithm executed by the GPU to obtain faster processing efficiency.

[0086] The bus 302 may include a path to transmit information between the above components. The bus 302 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 302 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0087] The memory 303 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory), or may include a high-speed random access memory, or may include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0088] Optionally, the memory 303 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 301. The processor 301 is used to execute the application code stored in the memory 303 to implement the method for implementing dynamic file real-time synchronization based on Linux provided in any embodiment of the present application.

[0089] The memory 303 can be used to store computer executable program codes, which include instructions. The processor 301 executes various functional applications and data processing of the electronic device 300 by running the instructions stored in the memory 303. The memory 303 may include a program storage area and a data storage area. Among them, the program storage area may store the code of the operating system, application program, etc. The data storage area may store data created during the use of the electronic device 300 (such as images, videos, etc. collected by the camera application), etc.

[0090] The memory 303 may also store one or more computer programs corresponding to the method for implementing real-time dynamic file synchronization based on Linux provided in the embodiment of the present application. The one or more computer programs are stored in the above-mentioned memory 303 and are configured to be executed by the one or more processors 301, and the one or more computer programs include instructions, and the above-mentioned instructions can be used to execute each step in the above-mentioned corresponding embodiment.

[0091] Of course, the code of the method for implementing dynamic file real-time synchronization based on Linux provided in the embodiment of the present application can also be stored in an external memory.

[0092] The display screen 305 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 300 may include 1 or N display screens 305, where N is a positive integer greater than 1. The display screen 305 can be used to display information input by a user or information provided to a user and various graphical user interfaces (GUI). For example, the display screen 305 can display photos, videos, web pages, or files.

[0093] The electronic device provided in the embodiment of the present application is applicable to any embodiment of the above method. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, which will not be repeated here.

[0094] An embodiment of the present invention also provides a computer-readable storage medium capable of implementing all the steps in the method in the above embodiment, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all the steps in the method in the above embodiment are implemented.

[0095] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0096] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.

[0097] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0098] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0099] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A method for realizing real-time synchronization of dynamic files based on Linux, characterized in that: include: S1. Generate a log file using a Java program, where the log file is used to record file change information; S2. Monitor the log file through a real-time synchronization script, obtain operation type information according to the log file information, and generate corresponding Linux commands according to the operation type information; S3. Check whether the target file path exists. If not, create it automatically and grant permissions to the directory according to the preset permissions. S4. Execute the Linux command in the background to perform file synchronization, and record the operation result in a synchronization result log file, where the synchronization result log file is used to check file consistency; S5. Compare the log file and the synchronization result log file using a consistency check script, and resynchronize the data with incorrect data consistency according to the comparison result.

2. The method according to claim 1, characterized in that: The step S5 of resynchronizing the data with incorrect data consistency according to the comparison result further includes: If the comparison result shows that there is an unsynchronized file, the unsynchronized file is found by traversing the log file, and the unsynchronized file is resynchronized.

3. The method according to claim 2, characterized in that Resynchronizing the unsynchronized files further includes: Determine the source file path and the target file path of the unsynchronized file; Execute the Linux command to copy the unsynchronized file from the source path to the target path; The operation result is synchronized to the synchronization result log file.

4. The method according to claim 1, characterized in that: The step S5 of resynchronizing the data with incorrect data consistency according to the comparison result further includes: If the comparison result shows that there is a synchronization error file, the synchronization result log file is searched to find the synchronization error file, and the synchronization error file is resynchronized.

5. The method according to claim 1, characterized in that In the step S1, using the Java program to generate a log file further includes: The real-time change events in the file system are captured, the real-time change events are converted into log entries, and the log file is generated according to the log entries.

6. The method according to claim 1, characterized in that The step S4 further comprises: A maximum connection number threshold is preset, and file synchronization is performed according to the Linux command. When the number of connections for simultaneously synchronizing files exceeds the preset maximum connection number threshold, new file synchronization operations are queued until the current number of connections is reduced below the threshold due to completion of the synchronization operation.

7. The method according to claim 1, characterized in that The step S3 checks whether the target file path exists, and automatically creates the target file path if it does not exist, further comprising: According to the hierarchical structure of the file path to be synchronized, the same hierarchical structure is created in the target file path accordingly.

8. A Linux-based dynamic file real-time synchronization system, characterized in that: include: A log file generation module is used to generate a log file using a Java program, wherein the log file is used to record file change information; A log file monitoring module, used to obtain operation type information according to the log file information, and generate corresponding Linux commands according to the operation type information; The path check module is used to check whether the target file path exists. If it does not exist, it will be automatically created and the directory will be authorized according to the preset permissions. A file synchronization module is used to execute the Linux command in the background to synchronize files and record the operation results in a synchronization result log file, where the synchronization result log file is used to check file consistency; The consistency comparison module is used to compare the log file and the synchronization result log file through a consistency check script, and resynchronize the data with incorrect data consistency according to the comparison result.

9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store operation instructions; The processor is used to execute the method according to any one of claims 1 to 7 by calling the operation instruction.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.