Sponsored Content
Top Forums Shell Programming and Scripting How to call a background process in perl? Post 302543492 by vanitham on Monday 1st of August 2011 03:08:55 AM
Old 08-01-2011
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

2. UNIX for Dummies Questions & Answers

background process

How, can I hide background process's output? (5 Replies)
Discussion started by: zylwyz
5 Replies

3. Shell Programming and Scripting

Perl Background Process - Finshed Yet?

I have a perl process I want to run in background in a cgi, but do not want to continue until process finished code looks like this. sub calc(){ do calculations return value } In another Perl program I call above function such as &calc(); I want to continue after process... (4 Replies)
Discussion started by: photon
4 Replies

4. Red Hat

Background process

If I run a process in the back ground like find . -name "abc" & after the process is complete we get a msg like + Done find . -name "abc" & Is it possible to redirect this msg to /dev/null Thanks for your help (1 Reply)
Discussion started by: Ujan
1 Replies

5. Solaris

background process

Hi When I run ./script.sh & the script runs in bg But when I close the telnet session, the script is killed also. any idea how to keep this script running? thx (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

6. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

7. Shell Programming and Scripting

How to process and run a program in the background in perl?

Hi, I have a query about processing and running Perl program at the background. I have HTML file called Userform.html which accepts input from the user. As soon as input is given the contol goes to get.cgi (get.cgi does some processing and computing tasks). Actually get .cgi takes more... (0 Replies)
Discussion started by: vanitham
0 Replies

8. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

9. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

10. Shell Programming and Scripting

Make background process interact with fg process

Hi, I have written a menu driven shell script in which as per the choice, I run the another script on background. For eg: 1. get info 2)process info 3)modify info All the operations have different scripts which i schedule in background using &. However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies
WAIT(1) 						    BSD General Commands Manual 						   WAIT(1)

NAME
wait -- await process completion SYNOPSIS
wait [pid] DESCRIPTION
If invoked with no arguments, the wait utility waits until all existing child processes in the background have terminated. Available operands: pid If a pid operand is specified, and it is the process ID of a background child process that still exists, the wait utility waits until that process has completed and consumes its status information, without consuming the status information of any other process. If a pid operand is specified that is not the process ID of a child background process that still exists, wait exits without waiting for any processes to complete. The wait utility exits with one of the following values: 0 The wait utility was invoked with no operands and all of the existing background child processes have terminated, or the process specified by the pid operand exited normally with 0 as its exit status. >0 The specified process did not exist and its exit status information was not available, or the specified process existed or its exit status information was available, and it terminated with a non-zero exit status. If the specified process terminated abnormally due to the receipt of a signal, the exit status information of wait contains that termination status as well. STANDARDS
The wait command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. BSD
June 5, 1993 BSD
All times are GMT -4. The time now is 01:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy