By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,215 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,215 IT Pros & Developers. It's quick & easy.

Background running proces monitor

P: 1

I am running a background command and want to mointor output of that commands which generate some flag files. When it finish it should be stopped.

I tried this
Expand|Select|Wrap|Line Numbers
  1. open(MON, "$CMD > output.txt |") || die "Can't start the $COMCOMM";
  2. while (<MON>) {
  3.    opendir(DIR, $dir) or die " Can't open $dir";
  4.     while ($file = readdir(DIR)) { 
  5.       if ($file eq "still_running_flag") {
  6.         print "$CMD is running...\n"; 
  7.         sleep 10;
  8.         next;
  9.       }
  10.     }
  11.    }
The problem is it is not running in background.

Feb 6 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 4,059
add $! to the die call and see if it helps determine why the command fails:

Expand|Select|Wrap|Line Numbers
  1. die "Can't start the $CDM : $!";

Edit: I possibly did not understand your question/problem. The process will not run in the background, it will run right then when you open/pipe to it, not sure what you are trying to do.
Feb 6 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.