9

First bash script is:

./second #takes too long

I want kill first bash script while second bash script is still running.

Can I do that?

UPDATE

First script run by cronjob!

6
  • 3
    Provide your scripts, not just a meaningless script name. Is the first script the parent process of the second? Commented Dec 23, 2014 at 19:31
  • Are you asking how to run the second script in the background so the first script can continue? ./second & Commented Dec 23, 2014 at 19:35
  • @tristan yes first script run second script Commented Dec 23, 2014 at 19:45
  • Then terminating the parent process will terminate the child. You can halt execution of whatever logic/actions in the first script, but it's process must live for the child to not be terminated. Commented Dec 23, 2014 at 19:46
  • 1
    Not always, you can disown a process, making it run independently of its parent. "that other guy" already gave you an answer, just add a & to the end of the process call. Read more about disowning processes here (found from a quick google search). Commented Dec 23, 2014 at 19:53

1 Answer 1

15

If the last thing that the first script does is to call the second script, then do this:

exec ./second

which replaces the first script's process with the second.

otherwise

nohup ./second &
disown
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.