Solved

graceful termination of a running script

Posted on 2014-09-18
2
244 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

948 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now