Solved

graceful termination of a running script

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Cannot add a NFS Server to Veeam as a repository 11 101
importing users to Security group 2 33
PC upgrade to Linux Mint 7 37
nagios 1 12
This article will show, step by step, how to integrate R code into a R Sweave document
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

744 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

12 Experts available now in Live!

Get 1:1 Help Now