Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

graceful termination of a running script

Posted on 2014-09-18
2
Medium Priority
?
269 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 2000 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

719 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