[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN111078382A - Command timeout processing method and device - Google Patents

Command timeout processing method and device Download PDF

Info

Publication number
CN111078382A
CN111078382A CN201911302225.1A CN201911302225A CN111078382A CN 111078382 A CN111078382 A CN 111078382A CN 201911302225 A CN201911302225 A CN 201911302225A CN 111078382 A CN111078382 A CN 111078382A
Authority
CN
China
Prior art keywords
command
target
target command
timeout
execution
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911302225.1A
Other languages
Chinese (zh)
Other versions
CN111078382B (en
Inventor
安卫杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN201911302225.1A priority Critical patent/CN111078382B/en
Publication of CN111078382A publication Critical patent/CN111078382A/en
Application granted granted Critical
Publication of CN111078382B publication Critical patent/CN111078382B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/524Deadlock detection or avoidance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Power Sources (AREA)

Abstract

The application provides a command timeout processing method and a device, wherein the method comprises the following steps: acquiring a target command and parameters thereof, a target identifier and timeout time, wherein the target identifier is used for executing timeout on the target command and indicating whether the target command needs to be forcibly exited or not; executing the target command; if the target command is not executed within the overtime time, performing overtime processing on the target command according to the target identifier: if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime; if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout. In the application, the user can set the target identification according to the self requirement, so that if the target command is overtime, the overtime target command is processed according to the user intention, and the user experience is better.

Description

Command timeout processing method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a command timeout processing method and apparatus.
Background
Shell is a scripting language written in C language and is also a user interface of the system. Briefly, the shell can receive commands input by a user and send the commands to the system for execution.
When executing the shell command, the shell command may be timed out, for example, trapping into a dead loop, or suspending the process, which results in excessive consumption of system resources and affects normal operation of the system.
Therefore, there is a need in the art for a method of handling timed-out shell commands.
Disclosure of Invention
In view of this, the present application provides a command timeout processing method and apparatus, which are used to process a timeout shell command, and the scheme is as follows:
a command timeout processing method, comprising:
acquiring a target command and parameters thereof, a target identifier and timeout time, wherein the target identifier is used for executing timeout on the target command and indicating whether the target command needs to be forcibly exited or not;
executing the target command;
if the target command is not executed within the overtime time, performing overtime processing on the target command according to the target identifier:
if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime;
if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout.
Preferably, the method further comprises the following steps:
detecting an execution result of the target command according to a preset detection period while executing the target command;
if the execution result of the target command is detected within the overtime time, returning the execution result of the target command;
and if the execution result of the target command is not detected within the overtime time, executing the overtime processing of the target command according to the target identifier.
Preferably, the method further comprises the following steps:
executing a sleep command while executing the target command, wherein the parameter of the sleep command is timeout;
if the execution result of the target command is detected within the timeout period, returning the execution result of the target command, including:
if the execution result of the target command is detected in the execution process of the sleep command, returning the execution result of the target command;
if the execution result of the target command is not detected within the timeout time, executing the timeout processing of the target command according to the target identifier, wherein the timeout processing comprises the following steps:
and if the execution result of the target command is not detected when the sleep command is executed, performing overtime processing on the target command according to the target identification.
Preferably, the method further comprises the following steps:
before executing the target command, creating a temporary file for recording an execution result of the target command;
detecting the execution result of the target command according to a preset detection period, wherein the method comprises the following steps:
and detecting whether the execution result of the target command exists in the temporary file according to a preset detection period.
Preferably, when performing timeout processing on the target command according to the target identifier, the method further includes:
recording indication information of target command execution overtime in a temporary file;
returning indication information of the execution timeout of the target command, comprising:
when the temporary file is detected to have the indication information of the execution timeout of the target command, the indication information of the execution timeout of the target command is returned.
A command timeout processing apparatus comprising:
the system comprises an acquisition module, a storage module and a control module, wherein the acquisition module is used for acquiring a target command and parameters thereof, a target identifier and timeout time, wherein the target identifier is used for executing timeout on the target command and indicating whether the target command needs to be forcibly exited or not;
the first execution module is used for executing the target command;
and the overtime processing module is used for performing overtime processing on the target command according to the target identifier if the target command is not executed within the overtime:
if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime;
if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout.
Preferably, the method further comprises the following steps:
the detection module is used for detecting the execution result of the target command according to a preset detection period while executing the target command;
the return module is used for returning the execution result of the target command when the detection module detects the execution result of the target command within the overtime time;
the timeout processing module is specifically configured to perform timeout processing on the target command according to the target identifier when the detection module does not detect the execution result of the target command within the timeout period.
Preferably, the method further comprises the following steps:
the second execution module is used for executing the sleep command while executing the target command, wherein the parameter of the sleep command is timeout;
the return module is specifically configured to return an execution result of the target command when the detection module detects the execution result of the target command in the sleep command execution process;
the timeout processing module is specifically configured to perform timeout processing on the target command according to the target identifier when the detection module finishes executing the sleep command and does not detect an execution result of the target command.
Preferably, the method further comprises the following steps:
a creating module for creating a temporary file for recording an execution result of the target command before the target command is executed;
the detection module is specifically configured to detect whether an execution result of the target command exists in the temporary file according to a preset detection period.
Preferably, the timeout processing module is further configured to record, in the temporary file, indication information that the target command is executed for a timeout;
the timeout processing module is specifically configured to, when the indication information of the target command execution timeout is returned, return the indication information of the target command execution timeout when it is detected that the indication information of the target command execution timeout exists in the temporary file.
According to the technical scheme, if the target command is not executed within the timeout period, the command timeout processing method provided by the application performs timeout processing on the target command according to the target identifier, and the timeout processing mode includes: if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime; if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout. In the application, the user can set the target identification according to the self requirement, so that if the target command is overtime, the overtime target command is processed according to the user intention, and the user experience is better.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a command timeout processing method according to an embodiment of the present disclosure;
fig. 2 is a flowchart of another command timeout processing method provided in the embodiment of the present application;
fig. 3 is a schematic structural diagram of a command timeout processing apparatus according to an embodiment of the present disclosure;
fig. 4 is a block diagram of a hardware structure of a command timeout processing device according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In view of the fact that the command timeout processing method in the prior art cannot be applied to various operating systems (e.g., aix (advanced Interactive executing), HP-ux (hewlett Packard unix), Solaris, Linux, etc.), and cannot process the timeout shell command according to the user's requirement, the present inventors have conducted intensive research and finally proposed a solution. The solution proposed by the inventors is described next by the following examples.
Referring to fig. 1, a flow diagram of a command timeout processing method is shown, where the method may include:
step S101, obtaining a target command and parameters thereof, a target identifier and timeout time.
The target command may be a shell command, the target identifier is used for indicating whether the target command needs to be forcibly exited after the target command is executed overtime, and the overtime time may be the time when the target command is normally executed. The target command and its parameters, target identification and timeout time may be entered by the user.
Preferably, after the data is acquired, the acquired data may be examined to determine whether it is legitimate. The examination content may include, but is not limited to, the following three points: firstly, checking whether the acquired data comprises a target command, a target identifier and overtime, if so, determining that the number of the acquired data is legal, otherwise, determining that the acquired data is illegal; secondly, checking whether the obtained target identification is a set value, such as 0 or 1, if so, determining that the obtained target identification is legal, otherwise, determining that the obtained target identification is illegal; thirdly, checking whether the obtained overtime time is an integer which is larger than or equal to zero, if so, determining that the obtained overtime time is legal, otherwise, determining that the obtained overtime time is illegal. In the embodiment of the application, if all the three checking contents are legal, the obtained data is determined to be legal, otherwise, the obtained data is illegal. Optionally, when it is determined that the acquired data is illegal, help information may be output to help the user to know how to perform correct input.
And step S102, executing the target command.
The present embodiment may execute the target command in a background running manner.
And step S103, if the target command is not executed within the timeout time, performing timeout processing on the target command according to the target identifier.
Wherein, the timeout processing procedure comprises: if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime; if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout.
It should be noted that, if the target command is not executed within the timeout period, it indicates that the target command is executed overtime, and otherwise, if the target command is executed within the timeout period, it indicates that the target command is not executed overtime.
In view of the fact that the processing operations required after the target command execution time-out may be different when the scenarios are different, based on this, the present embodiment sets the target identifier for indicating the time-out processing manner, so that when the target command execution time-out occurs, the time-out processing may be performed based on the target identifier.
Alternatively, the target flag may be set to 0 or 1, where 1 indicates that the target command needs to be forcibly exited and 0 indicates that the target command does not need to be exited. And when the target command is executed for timeout, if the target identifier is 1, forcibly quitting the target command and returning indication information of the execution timeout of the target command, and if the target identifier is 0, not quitting the target command and only returning the indication information of the execution timeout of the target command. If the target identifier is 1, the process corresponding to the target command can be forcibly killed through the kill command.
Illustratively, the target command is a find command, the timeout time is 10s, if the find command is not executed within 10 seconds, it indicates that the find command is executed overtime, at this time, timeout processing needs to be performed according to the target identifier, if the target identifier is 1, it indicates that the find command needs to be forcibly exited, at this time, the find command is forcibly exited, and indication information of the execution timeout of the find command is returned, if the target identifier is 0, it indicates that the find command does not need to be forcibly exited, at this time, only indication information of the execution timeout of the find command is returned.
According to the command timeout processing method provided by the application, if the target command is not executed within the timeout period, the target command is subjected to timeout processing according to the target identifier, and the timeout processing mode comprises the following steps: if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime; if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout. In the application, the user can set the target identification according to the self requirement, so that if the target command is overtime, the overtime target command is processed according to the user intention, and the user experience is better.
Those skilled in the art will appreciate that when the target command is executed, a corresponding execution result will be obtained. Based on this, the present embodiment may determine whether the target command is executed within the timeout period by whether the execution result of the target command is detected within the timeout period.
Specifically, in the present embodiment, while executing the target command, an execution result of the target command is detected according to a preset detection period; if the execution result of the target command is detected within the overtime time, the target command is indicated to be completely executed within the overtime time, namely the target command is not executed overtime, and at the moment, the execution result of the target command is returned; if the execution result of the target command is not detected within the timeout time, it indicates that the target command is not executed within the timeout time, that is, the target command is executed overtime, and at this time, the target command is subjected to overtime processing according to the target identifier.
The detection period may be determined according to actual conditions, for example, 1 second is used as the detection period, and whether the target command has an execution result may be detected every 1 second while the target command is executed.
According to the embodiment of the application, the execution result of the target command is detected according to the preset detection period, so that when the execution of the target command is not overtime, the execution result of the target command can be returned in time.
In an optional embodiment, the application may perform timing through a sleep command to determine whether an execution result of the target command is detected within a timeout period.
Specifically, while executing the target command, executing the sleep command, and detecting an execution result of the target command according to a preset detection period, where a parameter of the sleep command is timeout time, that is, a format of the sleep command is: sleep < timeout >; if the execution result of the target command is detected in the execution process of the sleep command, the execution of the target command is completed within the timeout time, namely the execution of the target command is not overtime, at the moment, the execution result of the target command is returned, if the execution result of the target command is not detected after the execution of the sleep command is completed, the execution of the target command is not completed within the timeout time, namely the execution of the target command is overtime, at the moment, the timeout processing is carried out according to the target identifier.
Illustratively, the target command is a find command, the target identifier is 1, the timeout time is 10 seconds, the sleep command is executed while the find command is executed, and the execution result of the find command is detected according to a preset detection period, if the execution result of the find command is detected in the execution process of the sleep command, the execution result of the find command is returned, and if the execution result of the find command is not detected after the sleep command is executed, the find command is forcibly exited, and indication information of the execution timeout of the find command is returned.
In an optional embodiment, the application may further create a temporary file before executing the target command, so that the execution result of the target command can be recorded in the temporary file. Based on this, the embodiment may detect whether the execution result of the target command exists in the temporary file according to a preset detection period.
If the execution result of the target command in the temporary file is detected within the overtime time, the target command is determined not to be executed overtime, the execution result of the target command is returned at the moment, if the execution result of the target command is not detected in the temporary file within the overtime time, the target command is determined to be executed overtime, and the target command is subjected to overtime processing according to the target identification at the moment.
If the execution of the target command is not timed out, the execution result of the target command is recorded in the temporary file, and if the execution of the target command is timed out, the indication information of the execution timeout of the target command is recorded in the temporary file.
In order to make the technical solution more understandable to those skilled in the art, a detailed description will be given below of a command timeout processing method provided in the embodiments of the present application.
Referring to fig. 2, a flowchart of another command timeout processing method according to an embodiment of the present application is shown, where the method optionally includes:
step S201, obtain the target command and its parameter, target identifier and timeout.
The target command is a shell command, the target identifier is used for indicating whether the target command needs to be forcibly exited when the target command is executed overtime, and the overtime time can be the time when the target command is normally executed.
Step S202, checking whether the acquired target command and the parameters, the target identification and the timeout time are legal.
Steps S201 to S202 correspond to step S101, and reference may be made to the foregoing description for details, which are not repeated herein.
It should be noted that, in step S202, before processing the overtime target command, the target command and its parameters, the target identifier, and the overtime time are checked, so that when the check result is illegal, the subsequent steps are not executed, and time is saved.
Step S203, if the target command and its parameters, target identifier, and timeout are legal, a temporary file for recording the execution result of the target command is created.
When the target command is executed, the execution result of the target command is recorded in the temporary file.
Step S204, executing the target command, executing the sleep command while executing the target command, and detecting whether the execution result of the target command exists in the temporary file according to a preset detection period.
Wherein, the parameter of the sleep command is timeout.
Optionally, the detection period may be 1 second, that is, the content in the temporary file is checked every 1 second, if the content is empty, the temporary file is continuously detected, and the detection is stopped until the content of the temporary file is not empty.
Step S205a, if the execution result of the target command is not detected in the temporary file after the sleep command is executed, performing timeout processing on the target command according to the target identifier, and recording instruction information of the target command execution timeout in the temporary file.
The process of performing timeout processing on the target command according to the target identifier includes: if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime; if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout.
Alternatively, the indication information of the execution timeout of the target command may be represented by "99", that is, "99" is recorded in the temporary file when the execution timeout of the target command is performed. When it is detected that "99" is recorded in the temporary file, 99 can be returned as a return code.
When the indication information of the target command execution timeout is detected in the temporary file, the detection process for the temporary file is ended.
Step S205b, if the execution result of the target command is detected in the temporary file during the execution of the sleep command, returns the execution result of the target command.
Optionally, when the execution result of the target command is detected, if the sleep command is not executed completely, the sleep command may be forcibly exited.
In the execution process of the sleep command, if the target command is executed completely, the execution result of the target command is recorded in the temporary file, and when the execution result of the target command recorded in the target file is detected according to a preset detection period, the execution result of the target command is returned.
The following describes the command timeout processing apparatus provided in the embodiments of the present application, and the command timeout processing apparatus described below and the command timeout processing method described above may be referred to in a corresponding manner.
Referring to fig. 3, a schematic structural diagram of a command timeout processing apparatus according to an embodiment of the present application is shown, and as shown in fig. 3, the command timeout processing apparatus may include: an acquisition module 301, a first execution module 302 and a timeout processing module 303.
The obtaining module 301 is configured to obtain a target command and a parameter thereof, a target identifier, and a timeout time.
The target mark is used for executing timeout in the target command and indicating whether the target command needs to be forcibly quitted or not.
A first executing module 302, configured to execute the target command.
The timeout processing module 303 is configured to perform timeout processing on the target command according to the target identifier if the target command is not executed within the timeout period:
if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime;
if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout.
According to the command timeout processing device provided by the application, if the target command is not executed within the timeout period, the target command is subjected to timeout processing according to the target identifier, and the timeout processing mode comprises the following steps: if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime; if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout. In the application, the user can set the target identification according to the self requirement, so that if the target command is overtime, the overtime target command is processed according to the user intention, and the user experience is better.
In a possible implementation manner, the command timeout processing apparatus provided in the embodiment of the present application may further include a detection module and a return module.
And the detection module is used for detecting the execution result of the target command according to a preset detection period while executing the target command.
And the return module is used for returning the execution result of the target command when the detection module detects the execution result of the target command within the overtime.
Correspondingly, the timeout processing module is specifically configured to perform timeout processing on the target command according to the target identifier when the detection module does not detect the execution result of the target command within the timeout period.
In a possible implementation manner, the command timeout processing apparatus provided in the embodiment of the present application may further include a second execution module.
And the second execution module is used for executing the sleep command while executing the target command.
Wherein, the parameter of the sleep command is timeout.
Correspondingly, the return module is specifically configured to return the execution result of the target command when the detection module detects the execution result of the target command in the execution process of the sleep command;
the timeout processing module is specifically configured to perform timeout processing on the target command according to the target identifier when the detection module finishes executing the sleep command and does not detect an execution result of the target command.
In a possible implementation manner, the command timeout processing apparatus provided in the embodiment of the present application may further include a creating module.
And the creating module is used for creating a temporary file for recording the execution result of the target command before the target command is executed.
Correspondingly, the detection module is specifically configured to detect whether the execution result of the target command exists in the temporary file according to a preset detection period.
In a possible implementation manner, the timeout processing module is further configured to record, in a temporary file, information indicating that the target command performs a timeout.
Correspondingly, the timeout processing module is specifically configured to, when the indication information of the target command execution timeout is returned, return the indication information of the target command execution timeout when the temporary file is detected to have the indication information of the target command execution timeout.
An embodiment of the present application further provides a command timeout processing device, please refer to fig. 4, which shows a block diagram of a hardware structure of the command timeout processing device, where the hardware structure of the command timeout processing device may include: at least one processor 401, at least one communication interface 402, at least one memory 403 and at least one communication bus 404;
in the embodiment of the present application, the number of the processor 401, the communication interface 402, the memory 403 and the communication bus 404 is at least one, and the processor 401, the communication interface 402 and the memory 403 complete communication with each other through the communication bus 404;
the processor 401 may be a central processing unit CPU, or an application specific Integrated circuit asic, or one or more Integrated circuits configured to implement embodiments of the present invention, or the like;
the memory 403 may include a high-speed RAM memory, and may further include a non-volatile memory (non-volatile memory) or the like, such as at least one disk memory;
wherein the memory 403 stores a program and the processor 401 may call the program stored in the memory 403 for:
acquiring a target command and parameters thereof, a target identifier and timeout time, wherein the target identifier is used for executing timeout on the target command and indicating whether the target command needs to be forcibly exited or not;
executing the target command;
if the target command is not executed within the overtime time, performing overtime processing on the target command according to the target identifier:
if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of target command execution overtime;
if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of target command execution timeout.
Alternatively, the detailed function and the extended function of the program may be as described above.
The embodiment of the application also provides a readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the command timeout processing method is realized.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A command timeout processing method, comprising:
acquiring a target command and parameters thereof, a target identifier and timeout time, wherein the target identifier is used for executing timeout on the target command and indicating whether the target command needs to be forcibly exited or not;
executing the target command;
if the target command is not executed within the timeout time, performing timeout processing on the target command according to the target identifier:
if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of the execution timeout of the target command;
and if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of the execution timeout of the target command.
2. The command timeout processing method according to claim 1, further comprising:
detecting an execution result of the target command according to a preset detection period while executing the target command;
if the execution result of the target command is detected within the overtime time, returning the execution result of the target command;
and if the execution result of the target command is not detected within the overtime time, executing the overtime processing of the target command according to the target identification.
3. The command timeout processing method according to claim 2, further comprising:
executing a sleep command while executing the target command, wherein the parameter of the sleep command is the timeout time;
if the execution result of the target command is detected within the timeout period, returning the execution result of the target command, including:
if the execution result of the target command is detected in the execution process of the sleep command, returning the execution result of the target command;
if the execution result of the target command is not detected within the timeout period, executing the timeout processing of the target command according to the target identifier, including:
and if the execution result of the target command is not detected when the sleep command is executed, performing overtime processing on the target command according to the target identification.
4. The command timeout processing method of claim 3, further comprising:
before executing the target command, creating a temporary file for recording an execution result of the target command;
the detecting the execution result of the target command according to the preset detection period comprises the following steps:
and detecting whether the execution result of the target command exists in the temporary file according to a preset detection period.
5. The command timeout processing method according to claim 2, wherein, when performing timeout processing on the target command according to the target identifier, the method further comprises:
recording indication information of the execution timeout of the target command in the temporary file;
the returning of the indication information of the target command execution timeout includes:
when the temporary file is detected to have the indication information of the execution timeout of the target command, returning the indication information of the execution timeout of the target command.
6. A command timeout processing apparatus, comprising:
the system comprises an acquisition module, a storage module and a control module, wherein the acquisition module is used for acquiring a target command and parameters thereof, a target identifier and timeout time, wherein the target identifier is used for executing timeout on the target command and indicating whether the target command needs to be forcibly exited or not;
the first execution module is used for executing the target command;
and the timeout processing module is used for performing timeout processing on the target command according to the target identifier if the target command is not executed within the timeout period:
if the target identification indicates that the target command needs to be forcibly exited, forcibly exiting the target command, and returning indication information of the execution timeout of the target command;
and if the target identification indicates that the target command does not need to be forcibly exited, returning indication information of the execution timeout of the target command.
7. The command timeout processing apparatus according to claim 6, further comprising:
the detection module is used for detecting the execution result of the target command according to a preset detection period while executing the target command;
the return module is used for returning the execution result of the target command when the detection module detects the execution result of the target command within the timeout time;
the timeout processing module is specifically configured to perform timeout processing on the target command according to the target identifier when the detection module does not detect the execution result of the target command within the timeout period.
8. The command timeout processing apparatus according to claim 7, further comprising:
a second executing module, configured to execute a sleep command while executing the target command, where a parameter of the sleep command is the timeout time;
the return module is specifically configured to return an execution result of the target command when the detection module detects the execution result of the target command in the execution process of the sleep command;
the timeout processing module is specifically configured to perform timeout processing on the target command according to the target identifier when the detection module does not detect the execution result of the target command after the sleep command is executed.
9. The command timeout processing apparatus according to claim 8, further comprising:
the creating module is used for creating a temporary file for recording the execution result of the target command before the target command is executed;
the detection module is specifically configured to detect whether an execution result of the target command exists in the temporary file according to a preset detection period.
10. The command timeout processing apparatus according to claim 7, wherein the timeout processing module is further configured to record, in the temporary file, information indicating that the target command is executed for a timeout;
the timeout processing module is specifically configured to, when returning the indication information that the execution of the target command is timeout, return the indication information that the execution of the target command is timeout when detecting that the indication information that the execution of the target command is timeout exists in the temporary file.
CN201911302225.1A 2019-12-17 2019-12-17 Command overtime processing method and device Active CN111078382B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911302225.1A CN111078382B (en) 2019-12-17 2019-12-17 Command overtime processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911302225.1A CN111078382B (en) 2019-12-17 2019-12-17 Command overtime processing method and device

Publications (2)

Publication Number Publication Date
CN111078382A true CN111078382A (en) 2020-04-28
CN111078382B CN111078382B (en) 2024-06-21

Family

ID=70315067

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911302225.1A Active CN111078382B (en) 2019-12-17 2019-12-17 Command overtime processing method and device

Country Status (1)

Country Link
CN (1) CN111078382B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112214300A (en) * 2020-10-12 2021-01-12 北京泽石科技有限公司 Command timeout processing method, processing device and computer readable storage medium
CN114003418A (en) * 2021-09-29 2022-02-01 苏州浪潮智能科技有限公司 Command timeout detection method, device and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744675A (en) * 2014-01-06 2014-04-23 浪潮(北京)电子信息产业有限公司 Engine and method for executing scripts and commands based on Linux pipeline technology
CN104899081A (en) * 2014-03-07 2015-09-09 无锡天脉聚源传媒科技有限公司 System and method for calling external executable command on the basis of JAVA technology
CN106254040A (en) * 2015-06-15 2016-12-21 中兴通讯股份有限公司 The response process method of order and device
CN106375435A (en) * 2016-08-31 2017-02-01 福建天晴数码有限公司 Web thread timeout monitoring method and system
CN109831520A (en) * 2019-03-07 2019-05-31 网宿科技股份有限公司 A kind of timed task dispatching method and relevant apparatus
CN110275785A (en) * 2019-04-28 2019-09-24 阿里巴巴集团控股有限公司 Data processing method, device, client and server

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744675A (en) * 2014-01-06 2014-04-23 浪潮(北京)电子信息产业有限公司 Engine and method for executing scripts and commands based on Linux pipeline technology
CN104899081A (en) * 2014-03-07 2015-09-09 无锡天脉聚源传媒科技有限公司 System and method for calling external executable command on the basis of JAVA technology
CN106254040A (en) * 2015-06-15 2016-12-21 中兴通讯股份有限公司 The response process method of order and device
CN106375435A (en) * 2016-08-31 2017-02-01 福建天晴数码有限公司 Web thread timeout monitoring method and system
CN109831520A (en) * 2019-03-07 2019-05-31 网宿科技股份有限公司 A kind of timed task dispatching method and relevant apparatus
CN110275785A (en) * 2019-04-28 2019-09-24 阿里巴巴集团控股有限公司 Data processing method, device, client and server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
翁小东: "基于UNIX C语言的一种线程池实现", 电脑知识与技术, vol. 5, no. 16, 30 June 2009 (2009-06-30), pages 2 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112214300A (en) * 2020-10-12 2021-01-12 北京泽石科技有限公司 Command timeout processing method, processing device and computer readable storage medium
CN112214300B (en) * 2020-10-12 2024-05-17 北京泽石科技有限公司 Method and device for processing command timeout and computer readable storage medium
CN114003418A (en) * 2021-09-29 2022-02-01 苏州浪潮智能科技有限公司 Command timeout detection method, device and system
CN114003418B (en) * 2021-09-29 2024-01-12 苏州浪潮智能科技有限公司 Command timeout detection method, device and system

Also Published As

Publication number Publication date
CN111078382B (en) 2024-06-21

Similar Documents

Publication Publication Date Title
CN108776595B (en) Method, device, equipment and medium for identifying display card of GPU (graphics processing Unit) server
CN110442502B (en) Point burying method, device, equipment and storage medium
JP2011233125A (en) Method and apparatus for handling intelligent bot utilizing camouflage virtual machine information
US10691390B2 (en) Method and device for video rendering
CN111078382A (en) Command timeout processing method and device
CN111651140B (en) Service method and device based on workflow
CN111597553A (en) Process processing method, device, equipment and storage medium in virus searching and killing
CN113330716B (en) Method and device for determining dependency relationship of application service and processor
CN110825451A (en) Method and device for configuring and verifying small program page address
CN111352710A (en) Process management method and device, computing equipment and storage medium
CN106874020A (en) Start the method and device of plug-in unit
CN113032100A (en) Exception handling method, device, equipment and storage medium
CN106130815B (en) Board level testing method and device
CN115952491A (en) Method, device, electronic equipment and medium for hook target function
CN114564720A (en) Program file auditing method and device, electronic equipment and storage medium
CN113672917A (en) Malicious code detection method and device, storage medium and electronic equipment
CN111191234B (en) Virus information detection method and device
CN114896021A (en) Malicious container detection method, system, device and host
CN112434287A (en) Method, device and equipment for detecting Hook and storage medium
CN111831551A (en) Non-blocking embedded software testing method, device and storage medium
CN115225194B (en) Time jump detection method and device, storage medium and computer equipment
CN112579430B (en) Processing method and device for acquisition codes
CN112468358B (en) Protocol detection method, system, equipment and computer readable storage medium
CN111178044B (en) Method and device for determining target text elements
CN109408244B (en) Application data acquisition method and device based on Azure WebJob

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant