1

Within Linux I would like Perl script A to launch Perl script B. However, I want script A to continue running without waiting for script B to return. And I would like B to be totally independent so that when script A ends, script B is still running.

Is this possible?

Daniel Kaplan
  • 701
  • 7
  • 19
  • https://stackoverflow.com/a/364884/5267751 – user202729 Nov 19 '18 at 05:39
  • 1
    Yes, launch B followed by `&` to background the process without waiting for a return. – David C. Rankin Nov 19 '18 at 05:47
  • Sounds like you are looking for [fork() & friends](https://en.wikipedia.org/wiki/Fork_(system_call)). For Perl implementation I would consult `man perlipc` or `man perlfork` – Stefan Becker Nov 19 '18 at 06:15
  • @DavidC.Rankin However, I would like to ignore the return from system as I am running the script from a browser. – Daniel Kaplan Nov 19 '18 at 06:56
  • Yes, yes, exactly. No requirement you wait for anything. It's a fire-and-forget proposition -- just like any good missile brought to you by the same people that first gave us a $200 hammer.... – David C. Rankin Nov 19 '18 at 09:18

1 Answers1

1

You can append an & sign at the end of your second script launch like this:

system("/script/myscript.sh $params &");

or

If your running one of this distros that won't let that work you'll have to use fork

or

Proc::Background
Agilanbu
  • 2,747
  • 2
  • 28
  • 33