Solved

graceful termination of a running script

Posted on 2014-09-18
2
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PowerShell logging 1 27
troubleshoot a python script 8 71
.dn property wont validate - Powershell 2 22
Ruby or Python 7 46
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

735 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