Subprocess management method, device, equipment and medium
By generating target command scripts with different script identifiers to manage subprocesses, the problem that the main process is difficult to distinguish and manage multiple subprocesses is solved, management efficiency is improved and resource waste is avoided.
Patent Information
- Application Number
- CN202210006476.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-05
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2042-01-05
AI Technical Summary
In the prior art, it is difficult for a main process to effectively distinguish and manage multiple sub-processes, resulting in resource waste and inefficient management.
By obtaining the initial command script, multiple target command scripts are generated, each with a different script identifier. Corresponding sub-processes are generated based on these scripts, so that the process identifier of each sub-process corresponds to the script identifier of the target command script it depends on, thereby achieving effective distinction and management of each sub-process.
It realizes the effective distinction and management of each sub-process, improves the management efficiency of the main process, and avoids resource waste.
Smart Images

Figure CN114385279B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of shell script technology, and in particular to a sub-process management method, apparatus, device and medium. Background Art
[0002] When using shell scripts for programming, you will often encounter a situation where the main process calls the same shell script to pass different parameters to generate multiple sub-processes. Since multiple sub-processes are generated by the same shell script, the names of the sub-processes generated by the shell script are the same, which makes it impossible to distinguish the sub-processes by the shell script name. It is difficult to achieve differentiation by parameters, and it is difficult for the main process to effectively manage the sub-processes. For example, the main process cannot forcefully stop certain sub-processes in the system command, and can only rely on the sub-process's own exit mechanism to wait for the sub-process to stop. However, if some sub-processes cannot exit on their own due to blocking, system resources will be occupied all the time, which will cause a waste of system resources. Therefore, the existing technology has the problem that the main process cannot effectively distinguish between the various sub-processes, resulting in low management efficiency. Summary of the Invention
[0003] The embodiments of the present invention provide a sub-process management method, apparatus, device and medium to achieve effective differentiation of sub-processes and facilitate management of sub-processes.
[0004] In a first aspect, an embodiment of the present invention provides a sub-process management method, the method comprising:
[0005] Get the initial command script to be called by the main process;
[0006] Determining target command scripts based on the initial command script, wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different;
[0007] For each target command script, a subprocess corresponding to the target command script is generated based on the target command script.
[0008] Optionally, determining each target command script based on the initial command script includes:
[0009] Based on the number of child processes to be generated corresponding to the initial command script, the initial command script is copied to obtain target command scripts;
[0010] Generate a script identifier corresponding to each target command script based on a unique naming rule.
[0011] Optionally, the method further includes:
[0012] Obtaining process identification information of each sub-process;
[0013] Determining resource consumption, runtime, and operating status of each of the sub-processes;
[0014] Based on the process identification information, the resource consumption conditions, the running time and the running status, the sub-process management information corresponding to each sub-process is generated.
[0015] Optionally, obtaining the process identification information of each sub-process includes:
[0016] Obtaining each sub-process query command, wherein the sub-process query command includes a script identifier of the target command script;
[0017] For each of the sub-process query commands, process identification information of the sub-process corresponding to the script identifier in the sub-process query command is determined based on the sub-process query command.
[0018] Optionally, generating a subprocess corresponding to the target command script based on the target command script includes:
[0019] Determining parameters to be passed based on the target command script;
[0020] A subprocess corresponding to the target command script is generated based on the parameters to be passed.
[0021] Optionally, the main process includes a first-level parent process, and the child process includes a second-level subtask.
[0022] Optionally, the main process further includes a second-level subtask, and the sub-process further includes a third-level subtask.
[0023] In a second aspect, an embodiment of the present invention further provides a sub-process management device, the device comprising:
[0024] The script acquisition module is used to obtain the initial command script to be called by the main process;
[0025] a script replication module, configured to determine target command scripts based on the initial command script, wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different;
[0026] A process generation module is used to generate a subprocess corresponding to each target command script based on the target command script.
[0027] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising:
[0028] one or more processors;
[0029] a storage device for storing one or more programs,
[0030] When the one or more programs are executed by the one or more processors, the one or more processors implement the sub-process management method provided by any embodiment of the present invention.
[0031] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the sub-process management method provided by any embodiment of the present invention.
[0032] The embodiments of the above invention have the following advantages or beneficial effects:
[0033] By obtaining the initial command script to be called by the main process, multiple target command scripts are generated based on the initial command script. The number of target command scripts generated is the same as the number of sub-processes generated after starting the initial command script, and the script identifiers of each target command script are different. For each target command script, a corresponding sub-process is generated through the target command script, so that the process identifier of each generated sub-process corresponds to the script identifier of the target command script it depends on, and thus the process identifiers of each sub-process are different from each other, thereby achieving effective distinction between each sub-process, facilitating management of each sub-process, and solving the technical problem of low efficiency of the main process in managing each sub-process in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings introduced here only illustrate some of the embodiments to be described by the present invention, and are not exhaustive. A person skilled in the art can derive other drawings based on these drawings without inventive effort.
[0035] Figure 1A A schematic diagram of a process flow of a sub-process management method provided in the first embodiment of the present invention;
[0036] Figure 1B A schematic diagram of hierarchical process management provided by the first embodiment of the present invention;
[0037] Figure 2A A schematic diagram of a process flow of a sub-process management method provided in the second embodiment of the present invention;
[0038] Figure 2B A schematic diagram of a process flow of a sub-process management method provided in the second embodiment of the present invention;
[0039] Figure 3 A schematic diagram of the structure of a sub-process management device provided in Embodiment 3 of the present invention;
[0040] Figure 4 This is a structural diagram of an electronic device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0041] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.
[0042] Example 1
[0043] Figure 1A This is a flow chart of a sub-process management method provided in the first embodiment of the present invention. This embodiment is applicable to programming using command scripts, such as shell scripts, where a main process calls the same command script to pass different parameters to generate multiple sub-processes. The method can be executed by a sub-process management device, which can be implemented by hardware and / or software. The method specifically includes the following steps:
[0044] S110: Obtain the initial command script to be called by the main process.
[0045] In this embodiment, a process can be an independent function of a program running on a certain data set. Specifically, a main process can be a process in the system for executing a main task, generating and managing other subtasks.
[0046] Specifically, the initial command script can be a programming language file called when the main process needs to spawn one or more child processes. The initial command script can be a shell script. Shell is a programming language that defines various variables and parameters and provides many control structures found only in high-level languages, including loops and branches. The main process can spawn one or more child processes by calling a shell script. In this embodiment, when the main process is detected to have invoked a call, the initial command script to be invoked by the main process can be obtained.
[0047] S120. Determine target command scripts based on the initial command script, wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different.
[0048] Specifically, after obtaining the initial command script to be called by the main process, one or more target command scripts can be generated based on the initial command script. The content of each generated target command script is identical to that of the initial command script; the number of generated target command scripts is equal to the number of child processes generated after launching the initial command script, i.e., the number of child processes that the main process expects to generate; and the script identifiers of each generated target command script are different.
[0049] Exemplarily, the main process can copy multiple copies of the initial command script and rename each of the copied initial command scripts according to a preset naming rule so that the script identifiers of each initial command script are different. That is, optionally, determining each target command script based on the initial command script can include: copying the initial command script based on the number of child processes to be generated corresponding to the initial command script to obtain each target command script; and generating a script identifier corresponding to each target command script based on a unique naming rule.
[0050] The number of child processes to be generated corresponding to the initial command script may be the number of child processes that the main process expects to generate. Specifically, the initial command script may be copied based on the number of child processes that the main process expects to generate, where the number of copies = the number of child processes to be generated corresponding to the initial command script - 1.
[0051] Furthermore, after the initial command script is copied, the original initial command script and each copied initial command script can be used as the target command script, and the script identifiers corresponding to the target command scripts can be renamed according to the naming uniqueness rule. The naming uniqueness rule can be to name the target command script based on a preset string that uniquely identifies the subprocess. For example, the script identifiers generated according to the naming uniqueness rule can be: "Task ID_01.sh," "Task ID_02.sh," "Task ID_03.sh," and "Task ID_04.sh."
[0052] S130. For each target command script, generate a subprocess corresponding to the target command script based on the target command script.
[0053] Specifically, after obtaining each target command script, the main process can generate a subprocess corresponding to each target command script by running each target command script. It should be noted that for each target command script, the process identifier of the generated subprocess corresponds to the script identifier of the target command script.
[0054] Continuing with the above example, the main process starts "Task ID_01.sh", "Task ID_02.sh", "Task ID_03.sh", and "Task ID_04.sh", generating child processes "Task ID_01", "Task ID_02", "Task ID_03", and "Task ID_04".
[0055] In one embodiment, generating a subprocess corresponding to the target command script based on the target command script includes: determining parameters to be passed based on the target command script; and generating a subprocess corresponding to the target command script based on the parameters to be passed. The parameters to be passed may be parameters in the target command script. Specifically, the main process may obtain the parameters to be passed by launching the target command script, and further generate a subprocess corresponding to the target command script based on the parameters to be passed.
[0056] By using the above method, the process ID of the generated sub-process can correspond to the script ID of the target command script it depends on, and the process IDs of each sub-process can be made different, which makes it easier for the main process to distinguish between the sub-processes.
[0057] In this embodiment, the main process optionally includes a first-level parent process, and the child process includes second-level subtasks. Specifically, when the main process is a first-level parent process, if the first-level parent process needs to generate one or more second-level subtasks, each target command script can be generated from the initial command script to be called. Furthermore, each second-level subtask is generated based on each target command script.
[0058] In another optional embodiment, the main process also includes a second-level subtask, and the sub-process also includes a third-level subtask. That is, if the second-level subtask needs to generate one or more third-level subtasks, the second-level subtask can obtain its initial command script to be called, generate each target command script based on the initial command script, and generate each third-level subtask through each target command script. Optionally, according to the original naming uniqueness rule, one or more character strings that can uniquely identify the third-level subtask can be formulated, such as "Task ID_0101", "Task ID_0102", and each target command script called by the third-level subtask can be renamed according to each character string, such as "Task ID_0101.sh", "Task ID_0102.sh".
[0059] For example, Figure 1B As shown, a hierarchical process management diagram is shown, see Figure 1BThe script identifier of the shell script that generates the first-level parent process is "parent process DEP.sh", and the script identifiers of the shell scripts that generate the second-level subtasks are "DEP_01.sh", "DEP_02.sh",..., the script identifiers of the shell scripts that generate the third-level subtasks from the second-level subtask "DEP_01.sh" are "DEP_0101.sh", "DEP_0102.sh", and the script identifiers of the shell scripts that generate the third-level subtasks from the second-level subtask "DEP_02.sh" are "DEP_0201.sh", "DEP_0202.sh".
[0060] For multi-level tasks, this embodiment can formulate or obtain a string that can identify the name of each subtask according to a certain naming rule, and rename the sub-shell scripts at each level. The main process can use the renamed script to find the process identifier of each subtask, thereby realizing hierarchical management of processes.
[0061] The technical solution of this embodiment is to obtain the initial command script to be called by the main process, generate multiple target command scripts based on the initial command script, the number of target command scripts generated is the same as the number of sub-processes generated after starting the initial command script, and the script identifiers of each target command script are different. For each target command script, a corresponding sub-process is generated through the target command script, so that the process identifier of each generated sub-process corresponds to the script identifier of the target command script it depends on, and thus the process identifiers of each sub-process are different from each other, thereby achieving effective distinction between each sub-process, facilitating management of each sub-process, and solving the technical problem of low efficiency of the main process in managing each sub-process in the prior art.
[0062] Example 2
[0063] Figure 2A This is a flow chart of a sub-process management method provided in the second embodiment of the present invention. Based on the above embodiments, this embodiment optionally further includes: obtaining process identification information of each sub-process; determining the resource consumption, running time and running status of each sub-process; and generating sub-process management information corresponding to each sub-process based on each process identification information, each resource consumption, each running time and each running status. The explanations of the terms that are the same or corresponding to the above embodiments are not repeated here. See Figure 2A The sub-process management method provided in this embodiment includes the following steps:
[0064] S210: Obtain an initial command script to be called by the main process, and determine each target command script based on the initial command script.
[0065] The number of the target command scripts is the same as the number of subprocesses generated after starting the initial command script, and the script identifiers of the target command scripts are different.
[0066] S220. For each target command script, generate a subprocess corresponding to the target command script based on the target command script.
[0067] S230: Obtain process identification information of each sub-process, and determine resource consumption, running time, and running status of each sub-process.
[0068] The process identification information of the sub-process may be information describing the process identification of the sub-process. In one embodiment, the main process may establish a mapping table between the process identification information of the sub-process and the script identification of the target command script, and then obtain the process identification information of the sub-process using the mapping table and the script identification of the target command script. Alternatively, when generating each sub-process, the main process may also generate an information table of the relationship between the main process and each sub-process based on the process identification information of each sub-process, and then obtain the process identification information of each sub-process using this information table.
[0069] In another embodiment, the obtaining of the process identification information of each sub-process may be: obtaining each sub-process query command, wherein the sub-process query command includes the script identification of the target command script; for each sub-process query command, determining the process identification information of the sub-process corresponding to the script identification in the sub-process query command based on the sub-process query command.
[0070] The sub-process query command can be a command for querying the sub-process corresponding to the script identifier of the target command script, such as ps-aux|grep "subtask ID.sh". Specifically, the sub-process query command includes the script identifier of the target command script to be queried. The main process can execute the sub-process query command to obtain the process identification information of the sub-process corresponding to the script identifier. Of course, the main process can also automatically generate a sub-process query command for querying the process identification information of all sub-processes corresponding to the target command scripts according to the script identifiers of all target command scripts, and automatically execute all sub-process query commands to obtain the process identification information of all sub-processes.
[0071] With this optional implementation, the main process doesn't need to maintain a correspondence between the script identifiers of each target command script and the process identifiers of its subprocesses. To manage a subprocess, the main process simply executes a subprocess query command to retrieve the subprocess's process identifier and manage it. Compared to maintaining a correspondence between subprocesses and target command scripts, and a table of relationship information between the main process and each subprocess, this method eliminates the need for relationship establishment and maintenance, reducing programming complexity and resource overhead.
[0072] Furthermore, after obtaining the process identification information of each sub-process, the main process can also obtain the resource consumption, runtime, and running status of each sub-process. Resource consumption can include the memory occupied by the sub-process; runtime can include the time from the start of the sub-process to the current moment; and running status can include the current execution state of the sub-process, such as normal or unresponsive.
[0073] S240: Generate sub-process management information corresponding to each sub-process based on the process identification information, the resource consumption status, the running time, and the running status.
[0074] Specifically, the main process can generate sub-process management information for each sub-process based on the process identification information, resource consumption, runtime, and running status of each sub-process. Through the sub-process management information, the main process can manage each sub-process. For example, when the main process detects that there is an unresponsive sub-process, it can terminate the sub-process based on the process identification information of the sub-process to complete resource recovery. Alternatively, when the main process detects that the resource consumption of a sub-process exceeds a preset resource threshold, it can terminate the sub-process based on the process identification information of the sub-process to complete resource recovery. Alternatively, when the main process detects that the runtime of a sub-process exceeds a preset time threshold, it can terminate the sub-process based on the process identification information of the sub-process to complete resource recovery.
[0075] For example, Figure 2B As shown in FIG, a flow chart of a sub-process management method is shown. In this method, first, the main process copies the shell script and renames each shell script, such as SonProcess.sh->DEP_01.sh; then, the main process calls each shell script, such as . / DEP_01.sh parameter A parameter B; finally, the main process periodically scans each sub-process according to the ID of each shell script and manages the sub-process, such as: ps-aux|grep "DEP_01.sh".
[0076] According to the technical solution of this embodiment, the main process can obtain the process identification information of each sub-process, and determine the resource consumption, running time and running status of each sub-process, and then establish the sub-process management information corresponding to each sub-process based on the process identification information, resource consumption, running time and running status of each sub-process, so that the main process can manage each sub-process through each sub-process management information, such as killing the sub-process that needs to be terminated, recovering the resources of the sub-process, etc., which is convenient for the main process to manage each sub-process.
[0077] Example 3
[0078] Figure 3 This is a structural diagram of a sub-process management device provided in Example 3 of the present invention. This embodiment is applicable to programming using command scripts, such as shell scripts, where the main process calls the same command script to pass different parameters to generate multiple sub-processes. The device specifically includes: a script acquisition module 310, a script copy module 320 and a process generation module 330.
[0079] The script acquisition module 310 is used to obtain the initial command script to be called by the main process;
[0080] a script copy module 320 for determining target command scripts based on the initial command script, wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different;
[0081] The process generation module 330 is configured to generate a sub-process corresponding to each target command script based on the target command script.
[0082] Optionally, the script copy module 320 is specifically configured to:
[0083] Based on the number of child processes to be generated corresponding to the initial command script, the initial command script is copied to obtain target command scripts; and script identifiers corresponding to the target command scripts are generated based on a unique naming rule.
[0084] Optionally, the device also includes an identification acquisition module and a resource management module; wherein the identification acquisition module is used to obtain the process identification information of each sub-process; the resource management module is used to determine the resource consumption, running time and running status of each sub-process; based on each process identification information, each resource consumption, each running time and each running status, the sub-process management information corresponding to each sub-process is generated.
[0085] Optionally, the identification acquisition module is specifically used to:
[0086] Obtain each sub-process query command, wherein the sub-process query command includes a script identifier of the target command script; for each sub-process query command, determine the process identifier information of the sub-process corresponding to the script identifier in the sub-process query command based on the sub-process query command.
[0087] Optionally, the process generation module 330 is specifically configured to:
[0088] Determine parameters to be passed based on the target command script; and generate a subprocess corresponding to the target command script based on the parameters to be passed.
[0089] Optionally, the main process includes a first-level parent process, and the child process includes a second-level subtask.
[0090] Optionally, the main process further includes a second-level subtask, and the sub-process further includes a third-level subtask.
[0091] In this embodiment, the script acquisition module is used to obtain the initial command script to be called by the main process, and the script copying module is used to generate multiple target command scripts based on the initial command script. The number of target command scripts generated is the same as the number of sub-processes generated after starting the initial command script, and the script identifiers of each target command script are different. The process generation module is used to generate a corresponding sub-process for each target command script through the target command script, so that the process identifier of each generated sub-process corresponds to the script identifier of the target command script on which it depends, and thus the process identifiers of each sub-process are different from each other, thereby achieving effective distinction between each sub-process, facilitating management of each sub-process, and solving the technical problem of low efficiency of the main process in managing each sub-process in the prior art.
[0092] The sub-process management device provided in the embodiment of the present invention can execute the sub-process management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0093] It is worth noting that the various units and modules included in the above system are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the embodiments of the present invention.
[0094] Example 4
[0095] Figure 4 This is a structural diagram of an electronic device provided in Example 4 of the present invention. Figure 4 A block diagram of an exemplary electronic device 12 suitable for implementing embodiments of the present invention is shown. Figure 4The electronic device 12 shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention. The device 12 is typically an electronic device that takes on the sub-process management function.
[0096] like Figure 4 As shown, the electronic device 12 is implemented as a general-purpose computing device. Components of the electronic device 12 may include, but are not limited to, one or more processors or processing units 16, a memory 28, and a bus 18 connecting the various components (including the memory 28 and the processing unit 16).
[0097] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MCA) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0098] The electronic device 12 typically includes a variety of computer-readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0099] The memory 28 may include computer-readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer storage media. By way of example only, the storage device 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 4 Not shown, often called a "hard drive"). Although Figure 4Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a Compact Disc-Read Only Memory (CD-ROM), a Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product 40 having a set of program modules 42 configured to perform the functions of various embodiments of the present invention. The program product 40 may be stored, for example, in the memory 28. Such program modules 42 include, but are not limited to, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0100] The electronic device 12 can also communicate with one or more external devices 14 (e.g., a keyboard, mouse, camera, etc., and a display), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). This communication can occur via an input / output (I / O) interface 22. Furthermore, the electronic device 12 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown, other hardware and / or software modules can be used in conjunction with the electronic device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) devices, tape drives, and data backup storage devices.
[0101] The processor 16 executes various functional applications and data processing by running the programs stored in the memory 28, such as implementing the sub-process management method provided in the above embodiment of the present invention, including:
[0102] Get the initial command script to be called by the main process;
[0103] Determining target command scripts based on the initial command script, wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different;
[0104] For each target command script, a subprocess corresponding to the target command script is generated based on the target command script.
[0105] Of course, those skilled in the art will appreciate that the processor may also implement the technical solution of the sub-process management method provided by any embodiment of the present invention.
[0106] Example 5
[0107] Embodiment 5 of the present invention further provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps of the sub-process management method provided in any embodiment of the present invention are implemented. The method includes:
[0108] Get the initial command script to be called by the main process;
[0109] Determining target command scripts based on the initial command script, wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different;
[0110] For each target command script, a subprocess corresponding to the target command script is generated based on the target command script.
[0111] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0112] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0113] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0114] The computer program code for performing the operations of the embodiments of the present invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0115] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. A sub-process management method, characterized in that: The method comprises: Get the initial command script to be called by the main process; Based on the number of sub-processes to be generated corresponding to the initial command script, the initial command script is copied to obtain each target command script; based on a naming unique rule, a script identifier corresponding to each target command script is generated; wherein, the number of the target command scripts is the same as the number of sub-processes generated after starting the initial command script, and the script identifiers of the target command scripts are different; for each target command script, a sub-process corresponding to the target command script is generated based on the target command script.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining process identification information of each sub-process; Determining resource consumption, runtime, and operating status of each of the sub-processes; Based on the process identification information, the resource consumption conditions, the running time and the running status, the sub-process management information corresponding to each sub-process is generated.
3. The method according to claim 2, characterized in that The obtaining of the process identification information of each sub-process includes: Obtaining each sub-process query command, wherein the sub-process query command includes a script identifier of the target command script; For each of the sub-process query commands, process identification information of the sub-process corresponding to the script identifier in the sub-process query command is determined based on the sub-process query command.
4. The method according to claim 1, wherein The generating a subprocess corresponding to the target command script based on the target command script includes: Determining parameters to be passed based on the target command script; A subprocess corresponding to the target command script is generated based on the parameters to be passed.
5. The method according to claim 1, wherein The main process includes a first-level parent process, and the child process includes a second-level subtask.
6. The method according to claim 5, characterized in that The main process also includes a second-level subtask, and the sub-process also includes a third-level subtask.
7. A sub-process management device, characterized in that: The device comprises: The script acquisition module is used to obtain the initial command script to be called by the main process; a script copying module, configured to copy the initial command script based on the number of child processes to be generated corresponding to the initial command script to obtain target command scripts; and generate script identifiers corresponding to the target command scripts based on a unique naming rule; wherein the number of the target command scripts is the same as the number of child processes generated after starting the initial command script, and the script identifiers of the target command scripts are different; The process generation module is used to generate a sub-process corresponding to each target command script based on the target command script.
8. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the sub-process management method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the sub-process management method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Process management method and process management device
CN105718307A
Process monitoring processing method and device
CN106569930A