A method for automatically synchronizing real time with OS and related components
By generating time zone marks and judging their consistency with the operating system's time zone definition, the problem of operating system error modifying system time during time synchronization is solved, and accurate real-life time synchronization is achieved.
Patent Information
- Application Number
- CN202210725417.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-24
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-06-24
AI Technical Summary
Because different operating systems have different time zone definitions of real-time clock time, the system time is incorrectly modified and the actual time required by the user cannot be accurately obtained.
By generating time zone marks, it is determined whether the time zone of the real-time clock time is consistent with the time zone definition of the operating system. If it is inconsistent, use the preset time conversion configuration to modify the system time to ensure the accuracy of the real time.
It avoids the system time being wrongly modified, ensures that the operating system believes that the real time is consistent with the real time required by the user, and improves the accuracy and reliability of time synchronization.
Smart Images

Figure CN115021856B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of time synchronization, and in particular to a method for automatically synchronizing real time with an OS and related components thereof. Background Art
[0002] When the server leaves the factory, the RTC (Real-Time Clock) chip in the server will keep timing, which is called RTC time. The RTC time may be the local time in the time zone where the server is produced, or it may be the time in the zero time zone, that is, UTC (Universal Time Coordinated). The server will install the OS (operating system) according to the RTC time, and obtain the RTC time as the system time used during the operation of the OS. However, since different OSs have different time zone definitions for RTC time, for example, regardless of the time zone in which the RTC time is actually, the Linux OS will regard the RTC time as the UTC time. After obtaining the RTC time as the system time, the Linux OS will modify the system time according to its time zone definition for the RTC time. When the time zone of the RTC time is not actually the UTC time, the Linux OS will eventually obtain the wrong real time, resulting in the real time that the OS considers is not the real time required by the user. Summary of the invention
[0003] The purpose of the present invention is to provide a method for automatically synchronizing the real time of an OS and its related components, which can avoid modifying the system time to an erroneous real time, so as to ensure that the real time considered by the OS is consistent with the real time required by the user.
[0004] In order to solve the above technical problems, the present invention provides a method for automatically synchronizing the real time of a server OS, comprising:
[0005] Generate a corresponding time zone mark according to the time zone corresponding to the RTC time in the RTC chip;
[0006] Using the RTC time as the system time of OS;
[0007] Determine whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS;
[0008] If they are consistent, the system time is converted into the real time according to the original time conversion configuration of the OS;
[0009] If they are inconsistent, modifying the system time according to the preset time conversion configuration corresponding to the OS, and using the modified system time as the actual time;
[0010] Wherein, the OS includes at least Linux OS and Windows OS.
[0011] Preferably, before generating the corresponding time zone mark according to the type of the RTC time in the RTC chip, it also includes:
[0012] Determine whether the current time is connected to the cloud time synchronization server;
[0013] If yes, the time recorded in the cloud time synchronization server is used as the actual time;
[0014] If not, the process proceeds to the step of generating a corresponding time zone mark according to the type of the RTC time in the RTC chip.
[0015] Preferably, when the OS is Windows OS, modifying the system time according to a preset time conversion configuration corresponding to the OS includes:
[0016] determining a time difference between a zero time zone and a time zone corresponding to the time zone definition;
[0017] The sum of the system time and the time difference is used as the modified system time.
[0018] Preferably, when the OS is a Linux OS, converting the system time into the real time according to the original time conversion configuration of the OS includes:
[0019] Setting the isutc configuration in the OS as a valid configuration;
[0020] The RTC time is converted into the real time using the isutc configuration.
[0021] Preferably, after generating the corresponding time zone mark according to the type of the RTC time in the RTC chip, it also includes:
[0022] sending said time zone marker to PNOR;
[0023] Determining whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS includes:
[0024] Determine whether the time zone corresponding to the time zone mark stored in the PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS;
[0025] If the time zone corresponding to the time zone mark stored in the PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be consistent;
[0026] If the time zone corresponding to the time zone mark stored in the PNOR is inconsistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be inconsistent.
[0027] Preferably, before generating a corresponding time zone mark according to the time zone corresponding to the RTC time in the RTC chip, the method further includes:
[0028] According to the user instruction, the time zone corresponding to the RTC time is modified to the time zone corresponding to the user instruction.
[0029] Preferably, when the OS is a Linux OS, modifying the system time according to a preset time conversion configuration corresponding to the OS includes:
[0030] Setting the isutc configuration in the OS to an invalid configuration;
[0031] The system time is used as the real time.
[0032] The present invention also provides a system for automatically synchronizing real time with an OS, comprising:
[0033] A tag generation unit, used to generate a corresponding time zone tag according to the time zone corresponding to the RTC time in the RTC chip;
[0034] A system time determination unit, configured to use the RTC time as the system time of the OS;
[0035] a judgment unit, configured to judge whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS; if they are consistent, triggering the first time determination unit; if they are inconsistent, triggering the second time determination unit;
[0036] The first time determination unit is used to convert the system time into real time according to the original time conversion configuration of the OS;
[0037] The second time determination unit is used to modify the system time according to a preset time conversion configuration corresponding to the OS, and use the modified system time as the actual time.
[0038] The present invention also provides a device for automatically synchronizing real time with an OS, comprising:
[0039] Memory for storing computer programs;
[0040] The processor is used to implement the steps of the above-mentioned method of automatically synchronizing the real time of the OS when executing the computer program.
[0041] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for automatically synchronizing the real time of the OS as described above are implemented.
[0042] The present invention provides a method for automatically synchronizing the real time of an OS and its related components, which relate to the field of time synchronization. A corresponding time zone mark is generated according to the time zone of the RTC time, the RTC time is used as the system time of the OS, and it is determined whether the time zone represented by the time zone mark is consistent with the time zone represented by the time zone definition of the OS. If they are consistent, the system time is converted into the real time according to the original time conversion configuration of the OS, and if they are inconsistent, the system time is modified according to the preset time conversion configuration of the OS. Since the OS has a time zone definition for the RTC time, when the time zone of the RTC time is equal to the time zone defined by the time zone, the OS can execute the original steps, that is, the original time conversion configuration to convert the system time to obtain the real time. If they are not equal, the preset time conversion configuration is used to modify the system time to avoid modifying the system time into an erroneous real time, so as to ensure that the real time finally obtained is consistent with the real time required by the user. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the prior art and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0044] Figure 1 A flowchart of a method for automatically synchronizing real time on a server OS provided in this application;
[0045] Figure 2 A schematic diagram of the generation principle of real time confusion provided by this application;
[0046] Figure 3 A schematic diagram of the structure of a system for automatically synchronizing real time with an OS provided by the present application;
[0047] Figure 4 A schematic diagram of the structure of a device for automatically synchronizing real time with an OS provided in the present application. DETAILED DESCRIPTION
[0048] The core of the present invention is to provide a method for automatically synchronizing the real time of an OS and its related components, which can avoid modifying the system time into an erroneous real time to ensure that the real time considered by the OS is consistent with the real time required by the user.
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Please refer to Figure 1 , Figure 1 A flowchart of a method for automatically synchronizing real time of a server OS provided in this application includes:
[0051] S11: Generate a corresponding time zone mark according to the time zone corresponding to the RTC time in the RTC chip;
[0052] When the server leaves the factory, the manufacturer will set an RTC time for the RTC chip, which can be the actual time corresponding to the time zone where the server is produced, that is, the local time, or the actual time corresponding to the zero time zone, that is, the UTC time. Considering that simply obtaining the RTC time cannot determine which time zone the RTC time specifically represents, the corresponding time zone mark can be generated in advance according to the time zone represented by the RTC time. For example, when the RTC time is represented as local time, the RTC_LOCAL=1 mark is generated to indicate that the RTC time is local time; when the RTC time is represented as UTC time, the RTC_LOCAL=0 mark is generated to indicate that the RTC time is UTC time.
[0053] S12: Use the RTC time as the OS system time;
[0054] In order to avoid the problem of inaccurate RTC time caused by directly modifying the RTC time, in this application, when the OS uses the RTC time, it first generates a copy of the RTC time, and uses the copy of the RTC time as the system time of the OS. Subsequent operations are all to modify the system time of the OS, and the RTC time in the RTC chip is not directly modified, thereby avoiding the problem of inaccurate RTC time.
[0055] S13: Determine whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS;
[0056] Considering that the time zone corresponding to the RTC time is different from the time zone definition of the RTC time by the OS, time errors may occur. For example, the Linux OS will regard the RTC time as the UTC time, but when the RTC time is actually the local time instead of the UTC time, the Linux OS is equivalent to regarding the local time as the UTC time, causing the subsequent Linux OS to process the local time as the UTC time, resulting in the actual time finally displayed on the OS not being the actual time required by the user; or the Linux OS itself can display the actual time required by the user, but the actual time of the OS of the virtual machine installed on the Linux OS has a display error. Therefore, before processing the system time, it is necessary to first determine whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS.
[0057] S14: If they are consistent, the system time is modified according to the preset time conversion configuration corresponding to the OS, and the modified system time is used as the actual time;
[0058] When the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition, it means that the system time can be converted into the real time only according to the original steps or procedures of the OS. For example, in the time zone definition of the Linux OS, the RTC time is defined as the UTC time, and the RTC time is actually the UTC time. When the Linux OS is in the East 8 time zone, the RTC time is obtained as the system time, and then 8 hours is added to the system time to get the time in the East 8 time zone, that is, the real time required by the user.
[0059] S15: If they are inconsistent, the system time is modified according to the preset time conversion configuration corresponding to the OS, and the modified system time is used as the actual time;
[0060] Among them, the OS includes at least Linux OS and Windows OS.
[0061] When the time zone corresponding to the time zone mark is inconsistent with the time zone corresponding to the time zone definition, in order to prevent the OS from converting the system time into an erroneous real time, a time conversion configuration can be set in advance for the OS. For example, when the OS is a Linux OS, the Linux OS defines the time zone of the RTC time as UTC time, but the RTC time is actually the local time, then the system time can be treated directly as the real time without any processing. It can be seen that when the OS is a Linux OS, when the time zone corresponding to the time zone mark is inconsistent with the time zone corresponding to the time zone definition, its preset time conversion configuration is not to modify the system time.
[0062] It should also be noted that when the OS is Windows OS or other OS with time zone defined as local time zone, the system time can be modified in a similar manner. For example, when the OS is Windows OS and the OS is located in the East 8 time zone, since Windows OS regards the RTC time as local time, when the RTC time is actually also the local time, the system time can be directly regarded as the real time. When the RTC time is UTC time, the system time can be modified according to the time difference between the East 8 time zone and the zero time zone, and the modified system time can be used as the real time. That is, the preset time conversion configuration in the case of Windows OS is to modify the system time according to the time difference between the East 8 time zone and the zero time zone.
[0063] In summary, a corresponding time zone mark is generated according to the time zone of the RTC time, and the RTC time is used as the system time of the OS. It is determined whether the time zone represented by the time zone mark is consistent with the time zone represented by the time zone definition of the OS. If they are consistent, the system time is converted into the real time according to the original time conversion configuration of the OS. If they are inconsistent, the system time is modified according to the preset time conversion configuration of the OS. Since the OS has a time zone definition for the RTC time, when the time zone of the RTC time is equal to the time zone defined by the time zone, the OS can execute the original steps, that is, the original time conversion configuration to convert the system time to obtain the real time. If they are not equal, the preset time conversion configuration is used to modify the system time to avoid modifying the system time to the wrong real time, so as to ensure that the final real time is consistent with the real time required by the user.
[0064] Based on the above embodiments:
[0065] As a preferred embodiment, before generating the corresponding time zone mark according to the type of the RTC time in the RTC chip, it also includes:
[0066] Determine whether the current time is connected to the cloud time synchronization server;
[0067] If yes, the time recorded in the cloud time synchronization server is used as the actual time;
[0068] If not, the process proceeds to the step of generating a corresponding time zone mark according to the type of the RTC time in the RTC chip.
[0069] In order to improve the efficiency of OS synchronization of real time, in this application, considering that the time recorded in the cloud time synchronization server must be the local time corresponding to the time zone where the OS time zone is defined, before generating the time zone mark, it can be determined whether the current moment is connected to the cloud time synchronization server. If it is normally connected to the cloud time synchronization server, the time recorded in the cloud time synchronization server is obtained. Since the time recorded in the cloud time synchronization server must be correct, it can be directly used as the real time. If it is disconnected from the cloud time synchronization server, the subsequent steps of generating the corresponding time zone mark according to the type of RTC time in the RTC chip are entered. It can be seen that before generating the time zone mark, first determining whether the current moment is connected to the cloud time synchronization server can improve the efficiency of OS synchronization of real time.
[0070] As a preferred embodiment, when the OS is Windows OS, the system time is modified according to the preset time conversion configuration corresponding to the OS, including:
[0071] determining the time difference between the zero time zone and the time zone corresponding to the time zone definition;
[0072] The sum of the system time and the time difference is taken as the modified system time.
[0073] In order to accurately modify the system time, in this application, since the time zone where the OS itself is located is pre-defined, and the time zone of the RTC time in Windows OS is defined as the local time zone, when the RTC time is UTC time, the difference between the system time and the real time is determined based on the time difference between the time zone where the OS itself is located and the zero time zone, and then the system time is added with the time difference to obtain the real time required by the user. For example, when the Windows OS itself is located in the East 8 time zone and the RTC time is UTC time, it can be known that the East 8 time zone and the zero time zone are 8 hours apart, and the time difference is determined to be 8 hours. The system time plus the time after 8 hours is the real time in the East 8 time zone. It can be seen that the system time can be accurately modified based on the time difference to obtain accurate real time.
[0074] As a preferred embodiment, when the OS is a Linux OS, the system time is converted into the real time according to the original time conversion configuration of the OS, including:
[0075] Set the isutc configuration in OS to the effective configuration;
[0076] Use isutc configuration to convert RTC time to real time.
[0077] In order to accurately modify the system time, in this application, considering that some OS such as Linux OS have isutc configuration, in which the system time can be converted into real time through specific logic, when the RTC time is actually local time, although the isutc configuration will make mistakes in converting the system time, when the RTC time is actually UTC time, the isutc configuration can accurately convert the system time into real time. Specifically, it is possible to first determine whether the RTC time is UTC time according to the time zone identifier corresponding to the RTC time, and automatically modify the isutc configuration according to the judgment result. When the RTC time is UTC time, the isutc configuration in the time zone configuration of the OS can be set to valid, otherwise the isutc configuration is set to invalid, so that the isutc configuration works at the right time. Further, the step of determining whether the RTC time is UTC time can be performed during the installation of the OS, and the isutc configuration is installed when the RTC time is UTC time. If the RTC time is local time, the isutc configuration is not installed, which is equivalent to removing the isutc configuration from the OS to improve efficiency. It can be seen that by setting the isutc configuration, the system time can be accurately modified.
[0078] As a preferred embodiment, after generating the corresponding time zone mark according to the type of the RTC time in the RTC chip, it also includes:
[0079] Send time zone stamp to PNOR;
[0080] Determine whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS, including:
[0081] Determine whether the time zone corresponding to the time zone tag stored in PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS;
[0082] If the time zone corresponding to the time zone tag stored in PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be consistent;
[0083] If the time zone corresponding to the time zone mark stored in PNOR is inconsistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be inconsistent.
[0084] In order to improve the efficiency of OS synchronization of real time, in this application, considering that OS itself will not record the time zone mark in the RTC chip, if the time zone mark is stored in the RTC chip, since the steps of OS reading data in the RTC chip are relatively cumbersome, it is necessary to enter the OS interface and use specific instructions to read the time zone mark in the RTC chip, which makes the efficiency of OS synchronization of real time slower; in addition, it is also considered that OS may not be in an online state and cannot obtain the real time from the time synchronization server in the cloud. Therefore, the time zone mark can be stored in the firmware layer outside the OS, such as in PNOR (PNOR flash memory, PNOR flash memory), so as to directly call the time zone mark stored in PNOR, without the need to use specific instructions to read, in the absence of network and time synchronization server, as long as the RTC initial time setting and the time zone mark stored in PNOR are correct, then the real time finally displayed by the OS is the real time required by the user. It can be seen that storing the time zone mark in PNOR can not only improve the efficiency of OS synchronization of real time, but also ensure that the OS obtains the correct real time when the OS is not online.
[0085] As a preferred embodiment, before generating a corresponding time zone mark according to the time zone corresponding to the RTC time in the RTC chip, it also includes:
[0086] According to the user's instruction, the time zone corresponding to the RTC time is modified to the time zone corresponding to the user's instruction.
[0087] In order to modify the time zone corresponding to the RTC time, in this application, it is taken into account that the user may change the OS during use. When the user changes the OS, due to the different time definitions of the OS, the new OS may convert the RTC time into the wrong real time. Therefore, after the user changes the new OS, it is necessary to match the time zone corresponding to the RTC time with the new OS. Since the time zone definition of the new OS is known, a user instruction can be generated according to the time zone definition of the OS to modify the time zone corresponding to the RTC time. For example, when the new OS is a Linux OS, the time zone corresponding to the RTC time can be set to UTC time through the "#timedatectl set-rtc-local 0" instruction. Furthermore, in addition to modifying the original corresponding RTC time and the corresponding configuration file, the time zone mark of the RTC time can also be updated. It can be seen that the time zone corresponding to the RTC time can be modified well according to the user instruction.
[0088] As a preferred embodiment, when the OS is a Linux OS, the system time is modified according to a preset time conversion configuration corresponding to the OS, including:
[0089] Set the isutc configuration in the OS to an invalid configuration;
[0090] Use system time as real time.
[0091] In order to obtain accurate real time, in this application, considering that some OS such as Linux OS have isutc configuration, in which the system time can be converted into real time through specific logic, but when the RTC time is actually the local time, the isutc configuration will make an error when converting the system time. For example, please refer to Figure 2 , Figure 2 A schematic diagram of the principle of generating confusion of real time provided for this application, because Linux OS will regard RTC time as UTC time for its time definition of RTC time, but when RTC time is actually local time, it is equivalent to OS regarding local time as UTC time, if isutc is configured as a valid configuration, it will convert UTC time into local time, that is, convert system time into real time, but because the system time here is actually local time, it is equivalent to converting local time to obtain another wrong local time, so the obtained time is also wrong, and finally when the user finds that the real time is the wrong time, the wrong real time needs to be modified to be converted into the correct real time, it can be seen that the system time needs to jump several times before it can become the correct real time. Based on this, the isutc configuration can be set to an invalid configuration to avoid OS modifying the system time, and the system time can be directly used as the real time. It can be seen that by setting the isutc configuration to an invalid configuration, accurate real time can be obtained.
[0092] Please refer to Figure 3 , Figure 3 A schematic diagram of the structure of a system for automatically synchronizing real time with an OS provided in this application includes:
[0093] A tag generating unit 21 is used to generate a corresponding time zone tag according to the time zone corresponding to the RTC time in the RTC chip;
[0094] A system time determination unit 22, configured to use the RTC time as the system time of the OS;
[0095] The judging unit 23 is used to judge whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS; if they are consistent, the first time determining unit 24 is triggered; if they are inconsistent, the second time determining unit 25 is triggered;
[0096] The first time determination unit 24 is used to convert the system time into the real time according to the original time conversion configuration of the OS;
[0097] The second time determination unit 25 is used to modify the system time according to the preset time conversion configuration corresponding to the OS, and use the modified system time as the actual time;
[0098] Among them, the OS includes at least Linux OS and Windows OS.
[0099] For a detailed introduction to a system for automatically synchronizing real time with an OS provided in the present application, please refer to the above-mentioned embodiment of the method for automatically synchronizing real time with an OS, and the present application will not go into details here.
[0100] As a preferred embodiment, it also includes:
[0101] The network determination unit is used to determine whether the current time is connected to the cloud time synchronization server before generating the corresponding time zone mark according to the type of the RTC time in the RTC chip; if so, trigger the third time determination unit; if not, trigger the mark generation unit 21;
[0102] The time recorded in the cloud time synchronization server is used as the actual time.
[0103] As a preferred embodiment, when the OS is Windows OS, the first time determining unit 24 is specifically used for:
[0104] determining the time difference between the zero time zone and the time zone corresponding to the time zone definition;
[0105] The sum of the system time and the time difference is taken as the modified system time.
[0106] As a preferred embodiment, when the OS is Linux OS, the first time determining unit 24 is specifically used for:
[0107] Set the isutc configuration in OS to the effective configuration;
[0108] Use isutc configuration to convert RTC time to real time.
[0109] As a preferred embodiment, it also includes:
[0110] A sending unit, configured to send the time zone mark to the PNOR after generating a corresponding time zone mark according to the type of the RTC time in the RTC chip;
[0111] The judging unit 23 is specifically used for:
[0112] Determine whether the time zone corresponding to the time zone tag stored in PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS;
[0113] If the time zone corresponding to the time zone tag stored in PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be consistent;
[0114] If the time zone corresponding to the time zone mark stored in PNOR is inconsistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be inconsistent.
[0115] As a preferred embodiment, it also includes:
[0116] The modification unit is used to modify the time zone corresponding to the RTC time to the time zone corresponding to the user instruction according to the user instruction.
[0117] As a preferred embodiment, when the OS is Linux OS, the second time determining unit 25 is specifically used for:
[0118] Set the isutc configuration in the OS to an invalid configuration;
[0119] Use system time as real time.
[0120] Please refer to Figure 4 , Figure 4 A schematic diagram of the structure of a device for automatically synchronizing real time with an OS provided in this application includes:
[0121] A memory 31, used for storing computer programs;
[0122] The processor 32 is used to implement the steps of the method for automatically synchronizing the real time of the OS as described above when executing the computer program.
[0123] For a detailed introduction to a device for automatically synchronizing real time with an OS provided in the present application, please refer to the embodiment of the method for automatically synchronizing real time with an OS described above, and the present application will not go into details here.
[0124] The present application also provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method for automatically synchronizing the real time of the OS as described above are implemented.
[0125] For a detailed introduction to a computer-readable storage medium provided in the present application, please refer to the above-mentioned embodiment of the method for automatically synchronizing real time with an OS, and the present application will not go into details here.
[0126] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0127] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0128] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for automatically synchronizing real time of a server OS, characterized in that: include: According to the user's instruction, the time zone corresponding to the RTC time is changed to the time zone corresponding to the user's instruction; Generate a corresponding time zone mark according to the time zone corresponding to the RTC time in the RTC chip; Using the RTC time as the system time of OS; Determine whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS; If they are consistent, the system time is converted into the real time according to the original time conversion configuration of the OS; If they are inconsistent, modifying the system time according to the preset time conversion configuration corresponding to the OS, and using the modified system time as the actual time; Wherein, the OS includes at least Linux OS and Windows OS; When the OS is Windows OS, modifying the system time according to a preset time conversion configuration corresponding to the OS includes: determining a time difference between a zero time zone and a time zone corresponding to the time zone definition; Taking the sum of the system time and the time difference as the modified system time; When the OS is a Linux OS, converting the system time into real time according to the original time conversion configuration of the OS includes: Setting the isutc configuration in the OS as a valid configuration; The RTC time is converted into the real time using the isutc configuration.
2. The method for automatically synchronizing real time of an OS according to claim 1, characterized in that: Before generating a corresponding time zone mark according to the time zone of the RTC time in the RTC chip, the method further includes: Determine whether the current time is connected to the cloud time synchronization server; If yes, the time recorded in the cloud time synchronization server is used as the actual time; If not, the process proceeds to the step of generating a corresponding time zone mark according to the time zone of the RTC time in the RTC chip.
3. The method for automatically synchronizing real time of an OS according to claim 1, characterized in that: After generating a corresponding time zone mark according to the time zone of the RTC time in the RTC chip, it also includes: sending said time zone marker to PNOR; Determining whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS includes: Determine whether the time zone corresponding to the time zone mark stored in the PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS; If the time zone corresponding to the time zone mark stored in the PNOR is consistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be consistent; If the time zone corresponding to the time zone mark stored in the PNOR is inconsistent with the time zone corresponding to the time definition of the RTC time by the OS, it is determined to be inconsistent.
4. The method for automatically synchronizing real time of an OS according to any one of claims 1 to 3, characterized in that: When the OS is a Linux OS, the system time is modified according to a preset time conversion configuration corresponding to the OS, including: Setting the isutc configuration in the OS to an invalid configuration; The system time is used as the real time.
5. A system for automatically synchronizing the real time with the OS, characterized in that: include: A mark generating unit, used for modifying the time zone corresponding to the RTC time to the time zone corresponding to the user instruction according to the user instruction, and generating a corresponding time zone mark according to the time zone corresponding to the RTC time in the RTC chip; a system time determining unit, configured to use the RTC time as the system time of an OS, wherein the OS includes at least a Linux OS and a Windows OS; a judgment unit, configured to judge whether the time zone corresponding to the time zone mark is consistent with the time zone corresponding to the time zone definition of the RTC time by the OS; if they are consistent, triggering the first time determination unit; if they are inconsistent, triggering the second time determination unit; The first time determination unit is used to convert the system time into real time according to the original time conversion configuration of the OS; The second time determination unit is used to modify the system time according to the preset time conversion configuration corresponding to the OS, and use the modified system time as the real time; when the OS is Windows OS, the second time determination unit is specifically used to determine the time difference between the zero time zone and the time zone corresponding to the time zone definition; use the sum of the system time and the time difference as the modified system time; when the OS is Linux OS, the second time determination unit is specifically used to set the isutc configuration in the OS as a valid configuration; and use the isutc configuration to convert the RTC time into the real time.
6. A device for automatically synchronizing the real time of an OS, characterized in that: include: Memory for storing computer programs; A processor is used to implement the steps of the method for automatically synchronizing the real time of the OS as described in any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for automatically synchronizing the real time of an OS as described in any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Time conversion method and device, equipment and storage medium
CN111399916A
Time display method and display equipment
CN111988648A