CN109725984B - Method for remotely stopping executing Shell command - Google Patents

Method for remotely stopping executing Shell command Download PDF

Info

Publication number
CN109725984B
CN109725984B CN201811584238.8A CN201811584238A CN109725984B CN 109725984 B CN109725984 B CN 109725984B CN 201811584238 A CN201811584238 A CN 201811584238A CN 109725984 B CN109725984 B CN 109725984B
Authority
CN
China
Prior art keywords
command
request
server
execution
shell
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.)
Active
Application number
CN201811584238.8A
Other languages
Chinese (zh)
Other versions
CN109725984A (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 Telecom Fufu Information Technology Co Ltd
Original Assignee
China Telecom Fufu Information 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 China Telecom Fufu Information Technology Co Ltd filed Critical China Telecom Fufu Information Technology Co Ltd
Priority to CN201811584238.8A priority Critical patent/CN109725984B/en
Publication of CN109725984A publication Critical patent/CN109725984A/en
Application granted granted Critical
Publication of CN109725984B publication Critical patent/CN109725984B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a method for remotely stopping an executing Shell command, which comprises the following steps: 1) The front-end page submits a request for executing the Shell command to the server; 2) The server side transmits a Shell command execution request to the command execution Agent; 3) The command execution Agent executes the Shell command on the host; 4) The server caches the received PID and the global unique ID returned by the Agent end, and updates the execution state to be 'executing'; 5) Update the front-end page "stop command" button as available; 6) If the currently executed Shell command needs to be stopped or the page is closed, clicking a stop command button or monitoring a page closing event, and sending a stop command request to the server by the front-end page; 7) The server side transmits a stop command request to the command execution Agent; 8) After receiving the stop command request, the command execution Agent executes a KILL PID command and ends the corresponding process; 9) The front end page prompts "process stop success". The invention can improve the user experience and avoid the waste of system resources.

Description

Method for remotely stopping executing Shell command
Technical Field
The present invention relates to a method of remotely stopping an executing Shell command.
Background
Currently, the Shell command is remotely executed through a front-end page, and if the executing command needs to be stopped, the PID is acquired through executing a PS command, and then the executing command needs to be stopped through the PID. It is difficult to accurately determine which command needs to be stopped if there are multiple commands of the same name executing even with human intervention. In addition, when the front-end page executes the remote Shell command, the command execution time is often too long, especially, certain query class commands mainly return query results to the executor, if the execution time is long and the executor already closes the page, the command continues to execute at the moment, which has no meaning, and unnecessary consumption is caused to system resources.
Disclosure of Invention
The invention aims to provide a method for remotely stopping the executing Shell command, which can improve the use experience of a user and avoid the waste of system resources.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method of remotely stalling an executing Shell command, the method comprising the steps of:
1) The front-end page submits a Shell command execution request to the server, the content of the Shell command execution request comprises a brand-new globally unique ID, and a thread is started to poll the server execution result;
2) After receiving a Shell command execution request from a front end, a server forwards the Shell command execution request to a command execution Agent, wherein the Shell command execution request content contains a global unique ID sent by a front end page;
3) The command execution Agent executes the Shell command on the host after receiving the Shell command execution request, returns the command immediately after the execution, and returns the PID and the global unique ID for executing the Shell command to the server;
4) The server caches the received PID and the global unique ID returned by the Agent end, and updates the execution state to be 'executing';
5) The front page polls to the server to change the execution state into 'executing', and meanwhile, the 'stop command' button of the front page is updated to be available;
6) If a currently executed Shell command needs to be stopped or a page is closed, clicking a stop command button or monitoring a page closing event, and sending a stop command request to a server by a front-end page, wherein the content of the stop command request comprises the global unique ID generated in the step 1);
7) The server receives the stop command request, forwards the stop command request to the command execution Agent, and the stop command request content comprises the globally unique ID sent by the front-end page;
8) After receiving the command stopping request, the command executing Agent executes a KILL PID command, ends a corresponding process and returns an execution result to the server;
9) The server returns the execution result to the front-end page, and the front-end page prompts that the process is stopped successfully.
By adopting the technical scheme, the invention has the following beneficial effects:
1. the executing command can be stopped at any time, and the use experience of the front end to remotely execute the Shell command is improved.
2. And when the page is closed, the executing command is stopped, so that the waste of system resources is avoided.
Detailed Description
The invention discloses a method for remotely stopping an executing Shell command, which comprises the following steps:
1) The front-end page submits a Shell command execution request to the server, the content of the Shell command execution request comprises a brand-new globally unique ID, and a thread is started to poll the server execution result;
2) After receiving a Shell command execution request from a front end, the server forwards the Shell command execution request to a command execution Agent, wherein the Shell command execution request content comprises a global unique ID sent by a front end page;
3) The command execution Agent executes the Shell command on the host after receiving the Shell command execution request, immediately returns the Shell command after the execution, and returns the PID and the global unique ID for executing the Shell command to the server;
4) The server caches the PID and the global unique ID returned by the Agent terminal, and updates the execution state to be 'executing';
5) The front-end page polls to change the execution state of the server into 'executing', and meanwhile, a 'stop command' button of the front-end page is updated to be available;
6) If the currently executed Shell command needs to be stopped or the page is closed, clicking a stop command button or monitoring a page closing event (monitoring page closing is optional operation), sending a stop command request to the server by the front-end page, wherein the content of the stop command request comprises the globally unique ID generated in the step 1);
7) The server receives the stop command request, forwards the stop command request to the command execution Agent, and the stop command request content comprises the globally unique ID sent by the front-end page;
8) After receiving the command stopping request, the command executing Agent executes a KILL PID command, ends a corresponding process and returns an execution result to the server;
9) The server returns the execution result to the front-end page, and the front-end page prompts that the process is stopped successfully.
The invention can be applied to scenes that the command execution time is long and the user does not want to wait or the user does not have significance to wait, and can automatically execute the stop command operation when the user closes the page or actively clicks the stop button, thereby avoiding unnecessary waiting. The user experience is improved, and the waste of system resources is avoided.
Although the preferred embodiments of the present patent have been described in detail, the present patent is not limited to the above embodiments, and various changes can be made without departing from the spirit of the present patent within the knowledge of those skilled in the art.

Claims (1)

1. A method of remotely stopping an executing Shell command, characterized by: the method comprises the following steps:
1) The front-end page submits a Shell command execution request to the server, the content of the Shell command execution request comprises a brand-new globally unique ID, and a thread is started to poll the server execution result;
2) After receiving a Shell command execution request from a front end, a server forwards the Shell command execution request to a command execution Agent, wherein the Shell command execution request content contains a global unique ID sent by a front end page;
3) The command execution Agent executes the Shell command on the host after receiving the Shell command execution request, returns the command immediately after the execution, and returns the PID and the global unique ID for executing the Shell command to the server;
4) The server caches the received PID and the global unique ID returned by the Agent end, and updates the execution state to be 'executing';
5) The front page polls to the server to change the execution state into 'executing', and meanwhile, the 'stop command' button of the front page is updated to be available;
6) If the currently executed Shell command needs to be stopped or the page is closed, clicking a stop command button or monitoring a page closing event, and sending a stop command request to a server by a front-end page, wherein the content of the stop command request comprises the globally unique ID generated in the step 1);
7) The server receives the stop command request, forwards the stop command request to the command execution Agent, and the stop command request content comprises the globally unique ID sent by the front-end page;
8) After receiving the command stopping request, the command executing Agent executes a KILL PID command, ends a corresponding process and returns an execution result to the server;
9) The server returns the execution result to the front-end page, and the front-end page prompts that the process is stopped successfully.
CN201811584238.8A 2018-12-24 2018-12-24 Method for remotely stopping executing Shell command Active CN109725984B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811584238.8A CN109725984B (en) 2018-12-24 2018-12-24 Method for remotely stopping executing Shell command

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811584238.8A CN109725984B (en) 2018-12-24 2018-12-24 Method for remotely stopping executing Shell command

Publications (2)

Publication Number Publication Date
CN109725984A CN109725984A (en) 2019-05-07
CN109725984B true CN109725984B (en) 2023-03-24

Family

ID=66297075

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811584238.8A Active CN109725984B (en) 2018-12-24 2018-12-24 Method for remotely stopping executing Shell command

Country Status (1)

Country Link
CN (1) CN109725984B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0768006A (en) * 1993-09-06 1995-03-14 Casio Comput Co Ltd Command processing method
CN101097527A (en) * 2006-06-27 2008-01-02 中国银联股份有限公司 Flowpath scheduling method and system of application progress
CN101916221A (en) * 2010-07-23 2010-12-15 中兴通讯股份有限公司 Method and system for performing unit testing on equipment
CN105099746A (en) * 2014-05-21 2015-11-25 中兴通讯股份有限公司 SHELL execution method and SHELL execution device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0768006A (en) * 1993-09-06 1995-03-14 Casio Comput Co Ltd Command processing method
CN101097527A (en) * 2006-06-27 2008-01-02 中国银联股份有限公司 Flowpath scheduling method and system of application progress
CN101916221A (en) * 2010-07-23 2010-12-15 中兴通讯股份有限公司 Method and system for performing unit testing on equipment
CN105099746A (en) * 2014-05-21 2015-11-25 中兴通讯股份有限公司 SHELL execution method and SHELL execution device

Also Published As

Publication number Publication date
CN109725984A (en) 2019-05-07

Similar Documents

Publication Publication Date Title
CN101290587B (en) Realization progress start-up and control process
WO2017071612A1 (en) Washing machine control method, control system and washing machine on internet of things
CN106254179B (en) Heartbeat packet asynchronous control method and device
WO2005043315A3 (en) System, method and computer program product for network resource processing
JP2010520528A5 (en)
JP2010146340A5 (en)
JP2011028430A5 (en)
CN109725984B (en) Method for remotely stopping executing Shell command
CN102098182A (en) Method for restoring allocation of distributed equipment and distributed equipment
EP2278464A3 (en) Relay device and relay method
US9977410B2 (en) Control system and method thereof
CN109062624B (en) Processing method for interrupt wakeup of automobile electronic control unit
CN106254505B (en) System and method for monitoring file uploading progress of FTP server side
CN110944064B (en) Remote access control system, method, device and medium for embedded network
CN106201667B (en) User instruction queue management system and method
CN107861897A (en) One kind is interrupted and poll triggering method, system, equipment and computer-readable storage medium
CN105159698B (en) A kind of flexible system crash monitoring system and its operating method
EP0701209A3 (en) Apparatus and methods for software rejuvenation
EP3602294B1 (en) Systems, methods, and apparatuses for pausing and resuming a virtual assistant
WO2019041246A1 (en) Method and device for retrieving unmanned aerial vehicle upon interruption of communication link, and computation device
CN112714048B (en) Intelligent device, control method, cloud platform, intelligent home system and storage medium
US20060150193A1 (en) Signal management in operations with multiple waits
CN108986800B (en) Logic real-time off-line voice interaction system and method based on multi-processor coordination linked list
CN111383633A (en) Voice recognition continuity control method and device, intelligent terminal and storage medium
CN113703802B (en) Data updating method and related device for storage management software

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