I have a script I would like to run as a background job on a Red Hat Linux box. When I run it without the "&", it runs fine. However, when I send it to the background (i.e. script.pl &), my top command does not execute. I tried everything to troubleshoot this issue but to no avail. What giveS? Thanks.
use strict;
open (OUT,">top.log") or die "cannot create: $!\n";
for (;;){
my $top = `top n 1`;
print $top;
sleep 10;
}
close OUT;