Solved

graceful termination of a running script

Posted on 2014-09-18
2
247 Views
Last Modified: 2014-09-18
Dear experts,

I wish to know how can I gracefully shut down a running bash script? For example, I may be running a script at current moment and that script may take about 1 min to complete. If I wish to interrupt the script, is there a way for me to wait for the script to complete before terminating the script? Thanks
0
Comment
Question by:Kinderly Wade
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 40331382
I think your question is a bit unclear.

>> is there a way for me to wait for the script to complete <<

Of course there is. Just wait for the prompt to reappear or check the process table (ps -ef) for the presence of your script.

On the other hand, if you mean terminating the script by sending it a signal - well, any signal except for SIGKILL ("9") is "graceful" in a way that there will be no open files or unflushed buffers left, thus not leaving (from the system's point of view) any data in an inconsistent state.
The most widely used signal in this scenario is SIGTERM ("15") or <Ctrl-C>

But of course there is no guarantee that the script will leave the data it worked on in a consistent state from the application's point of view!

You can allways add a trap handler to any of your scripts in order to catch one or more well-defined signals so the script will take appropriate actions before (possibly) terminating itself.
0
 

Author Comment

by:Kinderly Wade
ID: 40331567
Hi woolmilkporc,

Thanks for the prompt reply. You just answered question right on the spot. Thanks again.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
open source backup solution 1 36
number in printf 13 32
powershell script 9 64
IDE for Python 5 24
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question