How to call a background process in perl? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to call a background process in perl?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-01-2011
vanitham vanitham is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 8 October 2011, 3:32 AM EDT
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
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:

Code:
$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
Sponsored Links
    #2  
Old 08-01-2011
yazu yazu is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 25 May 2014, 1:25 AM EDT
Location: From far
Posts: 987
Thanks: 21
Thanked 232 Times in 226 Posts
Quote:
How to call an background process in perl?

Code:
system "cmd &"

Sponsored Links
    #3  
Old 08-02-2011
vanitham vanitham is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 8 October 2011, 3:32 AM EDT
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by yazu View Post
Code:
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
    #4  
Old 08-02-2011
yazu yazu is offline
Registered User
 
Join Date: Jun 2011
Last Activity: 25 May 2014, 1:25 AM EDT
Location: From far
Posts: 987
Thanks: 21
Thanked 232 Times in 226 Posts
Why don't try:

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

and see then what happens...
Sponsored Links
    #5  
Old 08-16-2011
vanitham vanitham is offline
Registered User
 
Join Date: Sep 2007
Last Activity: 8 October 2011, 3:32 AM EDT
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by yazu View Post
Why don't try:

Code:
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
Sponsored Links
    #6  
Old 08-16-2011
itkamaraj's Avatar
itkamaraj itkamaraj is offline Forum Advisor  
^Kamaraj^
 
Join Date: Apr 2010
Last Activity: 8 August 2014, 4:56 AM EDT
Posts: 3,057
Thanks: 33
Thanked 658 Times in 637 Posts

Code:
 
perldoc -q "background"

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to put FTP process as a background process/job in perl? vanitham Shell Programming and Scripting 5 07-18-2011 11:54 PM
Script to start background process and then kill process holocene UNIX for Dummies Questions & Answers 4 06-10-2010 03:39 AM
How to process and run a program in the background in perl? vanitham Shell Programming and Scripting 0 02-04-2010 02:14 AM
How to run background(child) process in PHP without blocking the usual flow of parent process on Lin elizas Linux 1 02-03-2010 05:13 PM
Perl Background Process - Finshed Yet? photon Shell Programming and Scripting 4 12-04-2007 12:30 PM



All times are GMT -4. The time now is 08:20 AM.