CN110968486A - Script running method and device - Google Patents

Script running method and device Download PDF

Info

Publication number
CN110968486A
CN110968486A CN201811145431.1A CN201811145431A CN110968486A CN 110968486 A CN110968486 A CN 110968486A CN 201811145431 A CN201811145431 A CN 201811145431A CN 110968486 A CN110968486 A CN 110968486A
Authority
CN
China
Prior art keywords
task
completed
script
record
target
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.)
Pending
Application number
CN201811145431.1A
Other languages
Chinese (zh)
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.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
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 Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201811145431.1A priority Critical patent/CN110968486A/en
Publication of CN110968486A publication Critical patent/CN110968486A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3414Workload generation, e.g. scripts, playback
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging

Abstract

The invention discloses a script running method and device, and aims to solve the problem that a script repeatedly executes a completed task when running is restarted after running fails. The method comprises the following steps: obtaining a completed task record, wherein the completed task record is used for indicating a completed task in a script; determining an initial position of the script operation according to the completed task record, wherein the initial position is a position after the last task in the completed task record; and continuing to execute the task in the script from the starting position.

Description

Script running method and device
Technical Field
The invention relates to the field of automatic testing, in particular to a script running method and device.
Background
A Script (Script) is an extension of a batch file, and is a program for storing plain text, and a general computer Script program is a combination of a predetermined series of operations for controlling a computer to perform an arithmetic operation, and can realize a certain logical branch or the like therein.
In a script for data processing, the script is used to schedule execution of a plurality of tasks (jobs). In the running process of the script, because a certain task in the middle makes mistakes during the execution, the running of the whole script fails, and the whole script is logged out by mistake. When the operation and maintenance personnel finishes processing the error report and reruns the script, all tasks in the script are executed from the beginning, and the tasks that have been executed and completed before need to be re-executed, which wastes time and system resources.
Disclosure of Invention
In view of the foregoing problems, an object of the embodiments of the present invention is to provide a script running method and apparatus, so as to solve the problem that when a script is run again after a running failure, a completed task is repeatedly executed.
In order to solve the above technical problems, embodiments of the present invention provide the following technical solutions:
in a first aspect, an embodiment of the present invention provides a script running method, where the method includes: obtaining a completed task record (didfile) indicating a completed task in the script; determining an initial position of the script operation according to the completed task record, wherein the initial position is a position after the last task in the completed task record; and continuing to execute the task in the script from the starting position.
In other embodiments of the present invention, the continuing to execute the task in the script from the starting position includes: starting to execute a target task from the initial position, wherein the target task is a task to be executed next to the last task in the completed task record; judging whether the target task is completed or not; when the target task is completed, recording the target task in the completed task record; and/or saving the completed task record according to the judgment result.
In other embodiments of the present invention, the saving the completed task record according to the determination result includes: when the target task is executed successfully, the completed task record is saved, wherein the completed task record comprises the target task which is executed successfully; when the target task is being executed, the completed task record is saved, whether the target task is completed or not is judged after a preset time interval, and the completed task record does not contain the target task being executed; and when the target task fails to be executed, saving the completed task record, and finishing running the script, wherein the completed task record does not contain the target task which fails to be executed.
In other embodiments of the present invention, when the target task fails to execute, saving the completed task record and ending running the script includes: when the target task fails to be executed, judging whether the last task in the completed task record is normal or not; when the last task is normal, the completed task record is saved, and the script is finished to run; and when the last task is abnormal, deleting the last task from the completed task record, continuously judging whether the last task of the last task is normal or not, stopping judging until the normal task is judged or the completed task record is empty, storing the completed task record, and finishing running the script.
In other embodiments of the present invention, the determining whether the last task in the completed task record is normal includes: and judging whether the last task in the completed task record is normal or not according to the output of the last task in the completed task record, wherein the output is the attribute of the output content of the last task in the completed task record during the execution.
In other embodiments of the present invention, the output comprises: the type of file, the size of the file, the output path of the file.
In other embodiments of the present invention, the determining whether the target task is completed includes: judging whether the target task is finished according to the return value of the target task; wherein the return value is used for indicating that the target task is abnormal during execution; when the return value is monitored, determining that the target task is not completed; and when the return value is not monitored, determining that the target task is completed.
In other embodiments of the present invention, after the recording the target task in the completed task record when the target task has been completed, the method further comprises: judging whether the target task is the last task in the script or not; when the target task is not the last task in the script, continuing to execute the next task of the target task; and when the target task is the last task in the script, ending the running of the script and deleting the completed task record.
In other embodiments of the present invention, the obtaining the completed task record includes: when the script is run for the first time, creating the completed task record; and when the script is re-run, acquiring the completed task record.
In other embodiments of the present invention, the continuing to execute the task in the script from the starting position includes: acquiring the completed tasks in the completed task records; acquiring a total task to be completed; determining uncompleted tasks in the script according to the total tasks to be completed and the completed tasks; generating a task list to be completed according to the uncompleted tasks, wherein the sequence of the uncompleted tasks in the task list to be completed is the same as that in the script; and starting from the starting position, and continuously executing the tasks in the script according to the sequence in the task list to be completed.
In a second aspect, an embodiment of the present invention provides a script execution apparatus, where the apparatus includes: an acquisition module configured to obtain a completed task record, the completed task record indicating a completed task in a script; the determining module is configured to determine an initial position of the script operation according to the completed task record, wherein the initial position is a position after the last task in the completed task record; an execution module configured to continue executing the task in the script from the starting location.
In a third aspect, an embodiment of the present invention provides an electronic device, including: memory, processor and computer program stored on the memory and executable on the processor, the processor implementing the method steps as described in one or more of the above claims when executing the program.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method according to one or more of the above technical solutions.
According to the script running method and device provided by the embodiment of the invention, firstly, a completed task record for indicating a completed task in a script is obtained; then, determining the initial position of script operation according to the completed task record; finally, the execution of the tasks in the script is continued from the starting position. It can be seen that the completed tasks in the script are recorded in the completed task records, when the script is run again after the running of the script fails, the running starting position of the script can be determined according to the completed tasks in the script stored in the completed task records, and the tasks in the script are continuously executed from the starting position, so that the script can be prevented from executing all tasks in the script from the beginning when the script is run again due to an error, the completed tasks in the script do not need to be executed again, only the incomplete tasks in the script are executed, and the time and the system resources can be saved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained according to the drawings without creative efforts for those skilled in the art.
FIG. 1 is a first flowchart illustrating a script execution method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating script execution after a target task execution failure in an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a script execution method according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a script execution apparatus in an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device in an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present invention, and not all embodiments. Other embodiments may be derived from these embodiments by those of ordinary skill in the art without the exercise of inventive faculty.
The embodiment of the invention provides a script running method, which can be applied to a script for data processing in practical application, for example: in the scheduling script of the Web 3.0ETL end, after an error is reported and exited in the running process of the script, when the script is re-run, the unfinished tasks in the script can be continuously executed according to the finished tasks in the script stored in the finished task record, so that the finished tasks in the script can be prevented from being executed again when the script is re-run, time and system resources can be saved, and specific application scenarios of the script running method are not specifically limited.
Specifically, the script execution method is executed by a script execution device, and the script execution device can be embedded in or externally connected to an electronic device.
In practical applications, the electronic device may be a terminal with information processing capability, such as: a server, a desktop computer, a notebook computer, etc., and the specific implementation form of the electronic device is not particularly limited herein.
The following describes a script running method provided by an embodiment of the present invention with reference to fig. 1.
Fig. 1 is a first flowchart illustrating a script running method in an embodiment of the present invention, and referring to fig. 1, the script running method includes:
s110: obtaining a completed task record;
wherein the completed task record is used to indicate the completed task in the script. The completed task record may be passively received by the script during the rerun, or actively acquired by the script during the rerun, and is not specifically limited herein. The completed task record records the completed tasks in the script when the last script is not completely run, wherein the completed tasks recorded in the completed task record may be the content of the completed tasks in the script, or the task names of the completed tasks, and is not specifically limited herein.
S120: determining the initial position of script operation according to the completed task record;
the method comprises the steps of recording tasks which are completed by a script when the last running of the script fails in a completed task record, determining the starting position of the script when the script is re-run after the last task in the completed task record in order to avoid the script from repeatedly executing the tasks which are completed by the script when the last running of the script fails in the re-running process, wherein no other tasks exist between the starting position and the last task in the completed task record, the tasks which are completed by the script are all before the starting position, and the tasks which are not completed by the script are all after the starting position.
S130: the execution of the tasks in the script continues from the starting position.
Specifically, the script is wrong in the running process, when the script runs again, the script firstly obtains a completed task record, and the completed task of the script in the last running is recorded in the completed task record; determining the initial position of script operation according to the completed task record by the script, wherein the tasks before the initial position in the script are all the tasks completed by the script in the last operation, and the tasks after the initial position in the script are all the tasks required to be executed by the script at this time; finally, the script continues to execute the tasks that are not completed in the script from the starting position. Therefore, when the script is operated again due to an error, all tasks in the script can be prevented from being executed from the beginning, the tasks completed in the script do not need to be executed again, only the tasks not completed in the script are executed, and time and system resources can be saved.
The script execution method is described below by way of example.
For example: there are four tasks in the script, which are: task a, task B, task C, and task D. When the script operates again, the script firstly obtains a completed task record, and the task A and the task B are recorded in the completed task record; determining the initial position of script operation according to the completed task record, wherein the initial position is just behind the task B and in front of the task C; finally, the script continues to execute task C and task D from the starting location. Therefore, when the script is restarted due to an error, the task A and the task B can be prevented from being executed again, but the script is executed from the task C, so that the time for executing the task A and the task B again can be saved, and system resources can be saved.
Based on the foregoing embodiment, in order to better avoid the script repeatedly executing the completed task when running again. Further, continuing to execute the task in the script from the starting position, comprising:
s1311: starting to execute the target task from the starting position;
and the target task is the next task to be executed of the last task in the completed task record.
S1312: judging whether the target task is completed;
s1313: when the target task is completed, recording the target task in the completed task record; and/or saving the completed task record according to the judgment result.
Specifically, the script continues to execute the task from the starting position, that is, the script first executes the target task, that is, the first task of the tasks to be executed in the script; then, judging whether the target task is completed or not so as to determine whether the target task can be recorded in a completed task record or not and avoid recording uncompleted tasks in the completed task record, wherein the target task is completed or not can mean whether the target task is successfully executed and completed or not; when the target task is determined to be completed, recording the target task in the completed task record so as to avoid repeated execution of the target task when the script is run again; or executing other operations according to the judgment result, and storing the completed task record to prevent the loss of the completed task record when the target task fails to be executed.
The target task may also be a task that is completed by manual operation in the manual operation and maintenance process.
Here, the other operation may be an operation taken on the target task, and further confirm whether the target task is completed, so as to avoid a problem of determining whether the target task is completed incorrectly; other operations can also be the operations taken on the completed task records, ensuring that all the records in the completed task records are the completed tasks; other operations can also be operations taken on the script, so that the script can be finished when one task in the script fails to be executed, and the script can be continuously executed subsequently.
It should be noted that, in the above embodiment, the method for recording the completed task in the completed task record is not only applicable to a scenario where the script re-runs to record the completed task in the script, but also applicable to a scenario where the script runs for the first time to record the completed task in the script, so that the tasks completed in the script before all the tasks are completed are recorded in the completed task record, and the task completed is prevented from being repeatedly executed when the script runs for the next time.
Based on the foregoing embodiment, in order to ensure that the tasks recorded in the completed task record are all completed tasks. Further, according to the judgment result, saving the completed task record, including:
when the target task is executed successfully, the completed task record is stored, and the completed task record comprises the target task which is executed successfully;
when the target task is being executed, the completed task record is stored, whether the target task is completed or not is judged after a preset time interval, and the completed task record does not contain the target task being executed;
and when the target task fails to be executed, saving the completed task record, and finishing running the script, wherein the completed task record does not contain the target task which fails to be executed.
Here, the determination result includes the following three cases:
the first situation is that the script successfully executes the target task, the target task can be recorded in the completed task record, and the completed task record is stored, so that the completed task record is prevented from being lost, the script can determine the starting position of the script operation according to the completed task record when the script operates again, and the script is prevented from repeatedly executing the completed task.
The second situation is that the script still executes the target task, and at this time, the target task is judged once again after a preset time interval, so as to avoid that the task being executed is mistakenly identified as the task failed to be executed, and further avoid that the script repeatedly executes the task when running again. The preset time interval may be a half or a third of an average execution time of one task in the script, so that the target task can be judged again in time and too frequent judgment of the target task can be avoided, and the preset time interval may be set according to a specific implementation condition, and is not limited specifically herein.
The third situation is that the script fails to execute the target task, at this time, the completed task record is saved, the script is finished, the manual script ending can be avoided, so that the script can be directly rerun, the completed task record is saved, the completed tasks recorded in the saved completed task record are all current completed tasks, and the repeated execution of partial completed tasks during the rerun of the script can be avoided.
Based on the foregoing embodiment, in order to ensure that the completed task recorded in the completed task record is a normally completed task. Further, fig. 2 is a schematic flowchart of a script running after a target task fails to be executed in the embodiment of the present invention, and referring to fig. 2, when the target task fails to be executed, a record of a completed task is saved, and the running of the script is finished, where the process includes:
s201: when the target task fails to be executed, judging whether the last task in the completed task record is normal or not, wherein S202 is executed when the last task is normal, and S203 is executed when the last task is abnormal;
s202: saving the completed task record, ending the running script,
s203: and deleting the last task from the completed task record, continuously judging whether the last task of the last task is normal or not, stopping judging until the normal task is judged or the completed task record is empty, storing the completed task record, and ending the running script.
In particular, multiple tasks in a script may be associated with each other, and the input of a subsequent task may depend on the output of a previous task. In two tasks related to each other, the previous task is stored in a completed task record after the execution is completed, when the execution of the next task fails, the next task may affect the previous task, so that the previous task becomes a task with the execution failure, but at this time, the previous task is already recorded in the completed task record, and after the script is re-run, only the next task is re-executed without executing the previous task, but the previous task is not successfully executed, so that an error occurs in the result of the overall running of the script.
In view of this, when the target task fails to be executed, it is necessary to determine whether the last task in the completed task record is normal, that is, whether the last task of the target task is normal or whether all tasks in the script associated with the target task are normal, so as to determine whether the completed tasks recorded in the completed task record and associated with the target task are normal, so as to ensure that the completed tasks recorded in the completed task record are all normally completed tasks.
Specifically, when it is determined that the last task in the completed task record is normal, it is described that the condition of the failed execution of the target task does not affect the completed task in the completed task record, and at this time, the completed task record is saved, and the running script is ended. When the last task in the completed task record is determined to be abnormal, the situation that the target task fails to execute influences the completed task recorded in the completed task record is shown, the last task in the completed task record is deleted from the completed task record, whether the last task of the last task is normal or not is continuously judged until the normal task is judged, or the last task in the current completed task record is judged to be normal or the completed task record is empty, the completed task record is stored, and the running script is finished. The completed task recorded in the completed task record can be guaranteed to be a normally completed task.
Based on the foregoing embodiment, it is convenient to determine whether the last task in the completed task record is normal. Further, the step of judging whether the last task in the completed task record is normal includes: and judging whether the last task in the completed task record is normal or not according to the output of the last task in the completed task record.
Here, the output may be an attribute of the output content when the task in the script executes. The task in the script may be the last task in the completed task record or the task that the script is executing.
Specifically, some contents may be output during or after the execution of the tasks in the script is completed, whether the last task in the completed task record is normal is judged by using the attribute of the output contents, and when the last task in the completed task record is judged to be normal, new contents do not need to be generated for judgment, so that the method is convenient and labor-saving, and the judgment efficiency can be improved.
Based on the foregoing embodiment, it is convenient to determine whether the last task in the completed task record is normal. Further, the outputting includes: the type of file, the size of the file, the output path of the file.
Specifically, the task in the script may have a file output during the execution process or after the execution is completed, the output file may be a result required by the user, whether the last task in the completed task record is normal can be judged by using the attribute of the file, and whether the last task in the completed task record is normal does not need to be judged by regenerating new information, so that the convenience and the trouble are saved, and meanwhile, whether the output file is a result required by the user can also be judged.
Here, the output may be an attribute of the file, for example: the type of the file, the size of the file, the output path of the file, etc., are not specifically limited herein.
Based on the foregoing embodiments, whether the target task is completed is determined for convenience. Further, judging whether the target task is completed or not includes: and judging whether the target task is completed or not according to the return value of the target task.
Wherein the return value is used for indicating that the target task is abnormal during execution.
Specifically, for all tasks in the script, the script monitors each executing task for exceptions during the script's execution. If the execution of the currently executed task fails, the script throws an exception, namely a return value; if the execution of the currently executing task is complete, the script will not throw any information during the execution of the currently executing task.
Specifically, when a return value is monitored, it is indicated that the target task fails to be executed, that is, the target task is not completed; when the return value is not monitored, the target task is successfully executed, namely the target task is completed. By monitoring the return value, whether the target task is completed or not can be conveniently judged.
Here, the return value may be information indicating that the task failed to be executed. The return value may be textual information, such as: when the return value shows "failure" or "Fail", it indicates that the current task failed to execute; the return value may also be digital information, such as: when the return value shows "1" or "0", it indicates that the current task failed to execute. The specific implementation form of the return value is not particularly limited herein.
Alternatively, whether or not the currently executing task fails, the script may throw a message indicating that the current task executed successfully or failed. For example: if the current task is successfully executed, the script throws out information indicating that the task is successfully executed; and if the currently executed task fails to execute, the script throws out information indicating that the task fails to execute. The specific implementation form for determining whether the currently executed task fails is not particularly limited herein.
Based on the foregoing embodiments, in order to ensure the integrity of the execution of tasks in a script. Further, after recording the target task in the completed task record when the target task has been completed, the method further comprises:
judging whether the target task is the last task in the script or not;
when the target task is not the last task in the script, continuing to execute the next task of the target task;
and when the target task is the last task in the script, ending the running of the script and deleting the record of the completed task.
Specifically, the script determines whether the target task is the last task in the script, a mark may be preset on the last task in the script, the mark is used to indicate that the task is the last task in the script, the mark may be text information or digital information, and a specific determination manner and a specific implementation form of the mark are not specifically limited herein as to whether the target task is the last task in the script.
Specifically, after the target task is executed and completed, when the script detects that the target task has the mark, the target task is determined to be the last task in the script, and the script is indicated to be completely and successfully run, at this time, the running of the script is finished, and the completed task record is deleted, wherein the deletion of the completed task record can also be the deletion of the content in the completed task record, so that the completed task in the script can be restarted to be recorded when the script is run next time, the completed tasks when the script is run and when the script is run failure are prevented from being recorded in the completed task record, and the accuracy of the content of the completed task record can be improved; when the script does not detect that the target task has the mark, the script is indicated to be not operated completely, and the script continues to execute the next task of the target task so as to ensure that all tasks in the script can be executed.
Based on the foregoing embodiment, in order to be able to record tasks that have been completed in a script. Further, obtaining a completed task record, comprising:
when the script is run for the first time, a completed task record is created;
when the script is re-run, a completed task record is obtained.
Specifically, when the script runs for the first time, there is no completed task record in the script, and when the script starts to run, a completed task record is automatically created to record the completed task in the script, or when the first task in the script is completed, a completed task record is created, and the time for creating the completed task record is not specifically limited herein. When the script operates again, the completed task record exists in the script, and the completed task record is recorded in the completed task record only by acquiring the completed task record, so that the repeated establishment of the completed task record is avoided.
It should be noted that the name of the created completed task record may be the date of the day to avoid overwriting the previously established completed task record, and the name of the completed task record is not specifically limited herein.
Based on the foregoing embodiment, in order to be able to continue executing tasks that are not completed in the script in the order of the tasks when the script is first run, the tasks are not completed. Further, S130 includes:
s1321: acquiring the completed tasks in the completed task records;
s1322: acquiring a total task to be completed;
s1323: determining unfinished tasks in the script according to the total tasks to be finished and the finished tasks;
s1324: generating a task list to be completed according to uncompleted tasks, wherein the sequence of the uncompleted tasks in the task list to be completed is the same as the sequence of the uncompleted tasks in the script;
s1325: and starting from the initial position, and continuing to execute the tasks in the script according to the sequence in the task list to be completed.
Specifically, the completed tasks are deleted from the total tasks to be completed, the uncompleted tasks can be obtained, the sequences of the uncompleted tasks are not changed, the uncompleted tasks are written into the task list to be completed, the uncompleted tasks in the script can be continuously executed according to the task list to be completed from the starting position, the phenomenon that the script omits individual uncompleted tasks when the uncompleted tasks are continuously executed is avoided, and all the tasks in the script are ensured to be executed.
Moreover, the method can also be applied to the first running of the script, when the script runs for the first time, the completed task record is empty, and no completed task exists, namely, the uncompleted task is the total task to be completed, the total task to be completed can be directly written into the task list to be completed, the task in the script can be executed according to the task list to be completed when the script runs for the first time, and the individual task in the script can be prevented from being missed to be executed. Compared with the to-be-completed task list generated in the process of re-running the script, the to-be-completed task list generated in the process of running the script for the first time does not need to be generated according to the completed task record and the total tasks to be completed, and the generation efficiency of the to-be-completed task list can be improved.
It should be noted that the task name recorded in the to-be-completed task list may be an unfinished task, and when the script is running again, the unfinished task in the script is executed according to the task name in the to-be-completed task list, so that the to-be-completed task list can be prevented from occupying too much space; the content recorded in the task list to be completed can be the content of the unfinished task corresponding to the script, when the script operates again, the unfinished task in the script can be executed completely only according to the task list to be completed, and the script running speed can be increased. The form of the incomplete task in the script recorded in the task list to be completed is not specifically limited herein.
In addition, in the process of executing the tasks in the task list to be completed, the script can only sequentially execute the tasks in the task list to be completed according to the task list to be completed; the task can be deleted from the to-be-completed task list after the first task in the to-be-completed task list is executed, and the first task in the current to-be-completed task list is continuously executed, so that the script is interrupted again in the running process and needs to be re-run again, the to-be-completed task list does not need to be generated again, unfinished tasks in the script can be continuously executed according to the existing to-be-completed task list, and unfinished tasks cannot be omitted. The form of executing the task in the to-be-completed task list is not particularly limited herein.
The following describes the operation process of the script execution method according to the embodiment of the present invention with a specific example.
Fig. 3 is a second flowchart illustrating a script execution method in an embodiment of the present invention, and referring to fig. 3, the script execution method includes:
s301: running the script;
s302: obtaining a completed task record, wherein when the completed task record is not obtained, S303 is performed, and when the completed task record is obtained, S304 and S305 are performed;
s303: creating a completed task record, and generating a to-be-completed task list, wherein the to-be-completed task list records a total task to be completed;
s304: acquiring the completed tasks in the completed task records;
s305: generating a task list to be completed according to the obtained completed tasks and the total tasks to be completed, wherein unfinished tasks are recorded in the task list to be completed;
s306: sequentially executing tasks in the task list;
s307: acquiring a return value of the task, wherein when the return value is not acquired, executing S308 and S309, and when the return value is acquired, executing S310;
s308: recording the task in a completed task record;
s309: judging whether the task is the last task in the script or not, wherein S312 is executed when the judgment result shows that the current task is the last task in the script, and S306 is executed when the judgment result shows that the current task is not the last task in the script;
s310: detecting the output of the last task in the completed task record, wherein when the error is input, S311 is executed, and when the output is correct, S312 is executed;
s311: deleting the last task in the completed task record, and executing S310 again;
s312: the script is ended.
According to the above, by recording the normally completed task in the completed task record and continuing to execute the task in the script through the to-be-completed task list generated by the completed task record, the repeated execution of the completed task in the re-operation of the script can be avoided, and the time and the system resources can be saved.
Based on the same inventive concept, the embodiment of the invention also provides a script running device. Fig. 4 is a schematic structural diagram of a script execution apparatus in an embodiment of the present invention, and referring to fig. 4, the script execution apparatus 400 includes: an obtaining module 401 configured to obtain a completed task record, where the completed task record is used to indicate a completed task in the script; a determining module 402, configured to determine, according to the completed task record, an initial position of script operation, where the initial position is a position after a last task in the completed task record; an execution module 403 configured to continue executing the task in the script from the starting location.
In other embodiments of the present invention, the execution module is configured to execute the target task from the start position, where the target task is a task to be executed next to a last task in the completed task record; judging whether the target task is completed; when the target task is completed, recording the target task in the completed task record; and/or saving the completed task record according to the judgment result.
In other embodiments of the present invention, the execution module is configured to, when the target task is successfully executed, save a completed task record, where the completed task record includes the target task that is successfully executed; when the target task is being executed, the completed task record is stored, whether the target task is completed or not is judged after a preset time interval, and the completed task record does not contain the target task being executed; and when the target task fails to be executed, saving the completed task record, and finishing running the script, wherein the completed task record does not contain the target task which fails to be executed.
In other embodiments of the present invention, the execution module is configured to determine whether a last task in the completed task record is normal when the target task fails to be executed; when the last task is normal, the completed task record is stored, and the running script is finished; and when the last task is abnormal, deleting the last task from the completed task record, continuously judging whether the last task of the last task is normal or not, stopping judging until the normal task is judged or the completed task record is empty, storing the completed task record, and ending the running script.
In other embodiments of the present invention, the execution module is configured to determine whether the last task in the completed task record is normal according to the output of the last task in the completed task record, and output the attribute of the output content of the last task in the completed task record during execution.
In other embodiments of the present invention, the output comprises: the type of file, the size of the file, the output path of the file.
In other embodiments of the present invention, the execution module is configured to determine whether the target task is completed according to a return value of the target task; the return value is used for indicating that the target task is abnormal in execution; when a return value is monitored, determining that the target task is not completed; and when the return value is not monitored, determining that the target task is completed.
In other embodiments of the present invention, the apparatus further comprises: an identification module; the identification module is configured to judge whether the target task is the last task in the script; when the target task is not the last task in the script, continuing to execute the next task of the target task; and when the target task is the last task in the script, ending the running of the script and deleting the record of the completed task.
In other embodiments of the present invention, the obtaining module is configured to create a completed task record when the script is run for the first time; when the script is re-run, a completed task record is obtained.
In other embodiments of the present invention, the execution module is configured to obtain a completed task in the completed task record; acquiring a total task to be completed; determining unfinished tasks in the script according to the total tasks to be finished and the finished tasks; generating a task list to be completed according to uncompleted tasks, wherein the sequence of the uncompleted tasks in the task list to be completed is the same as the sequence of the uncompleted tasks in the script; and starting from the initial position, and continuing to execute the tasks in the script according to the sequence in the task list to be completed.
Here, it should be noted that: the above description of the apparatus embodiments, similar to the above description of the method embodiments, has similar beneficial effects as the method embodiments. For technical details not disclosed in the embodiments of the apparatus according to the invention, reference is made to the description of the embodiments of the method according to the invention for understanding.
Based on the same inventive concept, an embodiment of the present invention further provides an electronic device, where the electronic device may include the script operating apparatus in the foregoing embodiment, and the electronic device may be a server, a desktop computer, a notebook computer, or the like. Fig. 5 is a schematic structural diagram of an electronic device in an embodiment of the present invention, and referring to fig. 5, the electronic device 500 includes: at least one processor 501; and at least one memory 502, bus 503 connected to processor 501; the processor 501 and the memory 502 complete communication with each other through the bus 503; the processor 501 is used for calling program instructions in the memory 502 to execute a script execution method as in one or more embodiments described above, and the processor 501 is configured to obtain a completed task record, where the completed task record is used for indicating a completed task in a script; determining the initial position of script operation according to the completed task record, wherein the initial position is the position after the last task in the completed task record; the execution of the tasks in the script continues from the starting position.
In other embodiments of the present invention, the processor is configured to execute a target task from a start position, where the target task is a task to be executed next to a last task in the completed task record; judging whether the target task is completed; when the target task is completed, recording the target task in the completed task record; and/or saving the completed task record according to the judgment result.
In other embodiments of the present invention, the processor is configured to save a completed task record when the target task is successfully executed, wherein the completed task record includes the successfully executed target task; when the target task is being executed, the completed task record is stored, whether the target task is completed or not is judged after a preset time interval, and the completed task record does not contain the target task being executed; and when the target task fails to be executed, saving the completed task record, and finishing running the script, wherein the completed task record does not contain the target task which fails to be executed.
In other embodiments of the present invention, the processor is configured to determine whether a last task in the completed task record is normal when the target task fails to execute; when the last task is normal, the completed task record is stored, and the running script is finished; and when the last task is abnormal, deleting the last task from the completed task record, continuously judging whether the last task of the last task is normal or not, stopping judging until the normal task is judged or the completed task record is empty, storing the completed task record, and ending the running script.
In other embodiments of the present invention, the processor is configured to determine whether the last task in the completed task record is normal according to the output of the last task in the completed task record, and output the attribute of the output content when the last task in the completed task record is executed.
In other embodiments of the present invention, the output comprises: the type of file, the size of the file, the output path of the file.
In other embodiments of the present invention, the processor is configured to determine whether the target task is completed according to a return value of the target task; the return value is used for indicating that the target task is abnormal in execution; when a return value is monitored, determining that the target task is not completed; and when the return value is not monitored, determining that the target task is completed.
In other embodiments of the present invention, the processor is further configured to determine whether the target task is the last task in the script; when the target task is not the last task in the script, continuing to execute the next task of the target task; and when the target task is the last task in the script, ending the running of the script and deleting the record of the completed task.
In other embodiments of the invention, the processor is configured to create a completed task record when the script is run for the first time; when the script is re-run, a completed task record is obtained.
In other embodiments of the present invention, a processor configured to obtain completed tasks in a completed task record; acquiring a total task to be completed; determining unfinished tasks in the script according to the total tasks to be finished and the finished tasks; generating a task list to be completed according to uncompleted tasks, wherein the sequence of the uncompleted tasks in the task list to be completed is the same as the sequence of the uncompleted tasks in the script; and starting from the initial position, and continuing to execute the tasks in the script according to the sequence in the task list to be completed.
Here, it should be noted that: the above description of the embodiments of the electronic device is similar to the description of the embodiments of the method described above, and has similar advantageous effects to the embodiments of the method. For technical details not disclosed in the embodiments of the electronic device according to the embodiments of the present invention, please refer to the description of the method embodiments of the present invention.
Based on the same inventive concept, embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the script execution method in one or more embodiments as described above.
Here, it should be noted that: the above description of the computer-readable storage medium embodiments is similar to the description of the method embodiments described above, with similar beneficial effects as the method embodiments. For technical details not disclosed in the embodiments of the computer-readable storage medium of the embodiments of the present invention, reference is made to the description of the method embodiments of the present invention for understanding.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A script execution method, the method comprising:
obtaining a completed task record, wherein the completed task record is used for indicating a completed task in a script;
determining an initial position of the script operation according to the completed task record, wherein the initial position is a position after the last task in the completed task record;
and continuing to execute the task in the script from the starting position.
2. The method of claim 1, wherein continuing to execute the task in the script from the starting location comprises:
starting to execute a target task from the initial position, wherein the target task is a task to be executed next to the last task in the completed task record;
judging whether the target task is completed or not;
when the target task is completed, recording the target task in the completed task record; and/or saving the completed task record according to the judgment result.
3. The method of claim 2, wherein saving the completed task record according to the determination comprises:
when the target task is executed successfully, the completed task record is saved, wherein the completed task record comprises the target task which is executed successfully;
when the target task is being executed, the completed task record is saved, whether the target task is completed or not is judged after a preset time interval, and the completed task record does not contain the target task being executed;
and when the target task fails to be executed, saving the completed task record, and finishing running the script, wherein the completed task record does not contain the target task which fails to be executed.
4. The method of claim 3, wherein saving the completed task record and ending running the script when the target task fails to execute comprises:
when the target task fails to be executed, judging whether the last task in the completed task record is normal or not;
when the last task is normal, the completed task record is saved, and the script is finished to run;
and when the last task is abnormal, deleting the last task from the completed task record, continuously judging whether the last task of the last task is normal or not, stopping judging until the normal task is judged or the completed task record is empty, storing the completed task record, and finishing running the script.
5. The method of claim 2, wherein after said recording said target task in said completed task record when said target task has been completed, said method further comprises:
judging whether the target task is the last task in the script or not;
when the target task is not the last task in the script, continuing to execute the next task of the target task;
and when the target task is the last task in the script, ending the running of the script and deleting the completed task record.
6. The method of any of claims 1 to 5, wherein the obtaining a completed task record comprises:
when the script is run for the first time, creating the completed task record;
and when the script is re-run, acquiring the completed task record.
7. The method of any of claims 1-5, wherein said resuming execution of tasks in the script from the starting location comprises:
acquiring the completed tasks in the completed task records;
acquiring a total task to be completed;
determining uncompleted tasks in the script according to the total tasks to be completed and the completed tasks;
generating a task list to be completed according to the uncompleted tasks, wherein the sequence of the uncompleted tasks in the task list to be completed is the same as that in the script;
and starting from the starting position, and continuously executing the tasks in the script according to the sequence in the task list to be completed.
8. A script execution apparatus, comprising:
an acquisition module configured to obtain a completed task record, the completed task record indicating a completed task in a script;
the determining module is configured to determine an initial position of the script operation according to the completed task record, wherein the initial position is a position after the last task in the completed task record;
an execution module configured to continue executing the task in the script from the starting location.
9. An electronic device, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the program.
10. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN201811145431.1A 2018-09-29 2018-09-29 Script running method and device Pending CN110968486A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811145431.1A CN110968486A (en) 2018-09-29 2018-09-29 Script running method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811145431.1A CN110968486A (en) 2018-09-29 2018-09-29 Script running method and device

Publications (1)

Publication Number Publication Date
CN110968486A true CN110968486A (en) 2020-04-07

Family

ID=70027121

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811145431.1A Pending CN110968486A (en) 2018-09-29 2018-09-29 Script running method and device

Country Status (1)

Country Link
CN (1) CN110968486A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103034554A (en) * 2012-12-30 2013-04-10 焦点科技股份有限公司 ETL (Extraction-Transformation-Loading) dispatching system and method for error-correction restarting and automatic-judgment starting
CN105224527A (en) * 2014-05-27 2016-01-06 北京宸瑞科技有限公司 Be applicable to the general ETL method of multiple object table update mode
US20160191845A1 (en) * 2014-12-31 2016-06-30 Chiun Mai Communication Systems, Inc. Electronic device and method for recording and displaying script
CN106951315A (en) * 2017-03-17 2017-07-14 北京搜狐新媒体信息技术有限公司 A kind of data task dispatching method and system based on ETL

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103034554A (en) * 2012-12-30 2013-04-10 焦点科技股份有限公司 ETL (Extraction-Transformation-Loading) dispatching system and method for error-correction restarting and automatic-judgment starting
CN105224527A (en) * 2014-05-27 2016-01-06 北京宸瑞科技有限公司 Be applicable to the general ETL method of multiple object table update mode
US20160191845A1 (en) * 2014-12-31 2016-06-30 Chiun Mai Communication Systems, Inc. Electronic device and method for recording and displaying script
CN106951315A (en) * 2017-03-17 2017-07-14 北京搜狐新媒体信息技术有限公司 A kind of data task dispatching method and system based on ETL

Similar Documents

Publication Publication Date Title
CN111782360A (en) Distributed task scheduling method and device
EP3142011A1 (en) Anomaly recovery method for virtual machine in distributed environment
US20130275807A1 (en) Information processing apparatus and installation method
CN105045617B (en) A kind of application recovery method and system of android system
CN109684130B (en) Method and device for backing up data of computer room
CN107766131B (en) Task scheduling method and device
US9268608B2 (en) Automatic administration of UNIX commands
CN110825758B (en) Transaction processing method and device
CN110968486A (en) Script running method and device
JP2006065440A (en) Process management system
CN109117277B (en) Method and device for simulating synchronous blocking in asynchronous environment, storage medium, server and terminal
CN105868957A (en) Continuous integration method and device
CN113342512B (en) IO task silencing and driving method and device and related equipment
US5291589A (en) System for controlling restoration from failure in queue structure of control data
CN114756410A (en) Data recovery method, device and medium for dual-computer hot standby system
CN111090575B (en) Test method
CN110990052B (en) Configuration preservation method and device
CN111444033A (en) Springbatch-based task fault-tolerant processing method and related equipment
CN111651350A (en) Test case processing method, device and equipment and computer readable storage medium
CN112487004A (en) Method, device, medium and system for automatically controlling task based on data blood margin
CN107797915B (en) Fault repairing method, device and system
CN111638965A (en) Command queue inter-fence synchronization method and system based on fence replication and handshake
CN110109740B (en) Crontab command execution method and device
CN106293897B (en) Automatic scheduling system of subassembly
CN109614116B (en) Installation method and device of embedded system

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200407