How to call a background process in perl?

Hi,

I want to put the following code as a parallel or background process

The program is as below:

$n=10; #Count of files to be created. 
for($j=0;$j<=$n;$j++) {
open(FH,">files_$j.txt") || warn "cannot create a file\n";
{
print FH "count of file: $j\n"; #Sample data to be written. just an example.
system("mv files_$j.txt /home/backup/remove/files") #put the following code as a parallel or background process
}
close FH;
}

Is it possible to make the "mv" command i.e. moving the files from current working directory to other directory
to be independent of the main code?

The first file gets created and then the MV command gets called and file gets transfered again the next file
gets created and MV command is called and so on. As a sample data i have given the count to be written what if
there is huge amount of data (around few GB) to be written and transferred. It takes quite large amount of time.

How can i make the file copying as an indepenent process?
file1 gets created -> MV is called as an background process
file 2 gets created but MV will be called in parallel not as a dependent process

File creation should not wait for the MV command as an background process?

How can i do it in Perl?

Regards
Vanitha

system "cmd &"

Hi,

How to call particular MV command as an background?

Should i need to call a separate program and put as an background

Regards
Vanitha

Why don't try:

system("mv files_$j.txt /home/backup/remove/files &")

and see then what happens...

Hi,

Thanks ..

But how to stop the background process?

I meant how to check for the end of background process?

Regards
VAnitha

 
perldoc -q "background"