I am running a perl script from a cron job on Ubuntu. As part of the script it needs to execute an external program and not wait for the program to complete and also continue executing the script. I have tried the following but as near as I can tell it is not executing the program and also seams to not continue the script.
exec("/usr/bin/dotnet /usr/local/myprogram/myprogram.dll arg1, arg2, moreargs")
or print STDERR "Couldn't exec myprogram";
exec
. (See https://perldoc.perl.org/functions/exec.html .) fork
(see https://perldoc.perl.org/functions/fork.html ) so that you have two separate processes running in parallel (one running the program, one running the rest of the script).So:
my $child_pid = fork();
die "Couldn't fork" unless defined $child_pid;
if (! $child_pid) {
exec '/usr/bin/dotnet', '/usr/local/myprogram/myprogram.dll', 'arg1', 'arg2', 'moreargs';
die "Couldn't exec myprogram: $!";
}
# rest of script
wait();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.