On Sep 12, 2006, at 9:59 PM, Owen Cook wrote:
Here's the script: #!/usr/bin/perl use warnings; use strict; my $log_file = '/home/james/code/cron_code/httpsd_mysqld_log_file'; open FILE_OUT, ">> $log_file" or die "Cannot open log file: $!"; select FILE_OUT; (my $month, my $day, my $year, my $hour, my $minute, my $second) = (localtime)[4, 3, 5, 2, 1, 0]; printf("%04s-%02s-%02s %02d:%02d:%02d ", $year+1900, $month, $day, $hour, $minute, $second); my $httpsd_count = `ps -aux | grep -c httpsd`; my $mysqld_count = `ps -aux | grep -c mysqld`; chomp($httpsd_count); chomp($mysqld_count); my $httpsd_msg = ''; my $mysqld_msg = ''; if ($httpsd_count > 0) { print "httpsd $httpsd_count "; } else { print "httpsd NOT RUNNING "; } if ($mysqld_count > 0) { print "mysqld $mysqld_count "; } else { print "mysqld NOT RUNNING "; } print "\n"; close FILE_OUT;I suspect that your env includes the path to "ps" For cron you would need the full path Try my $httpsd_count = `/usr/bin/ps -aux | grep -c httpsd`; my $mysqld_count = `/usr/bin/ps -aux | grep -c mysqld`;
I just tried that and let it run in cron but there's no difference in output. I still get "1"s in cron and process counts from the command line.
cron: 2006-08-12 22:15:20 httpsd 1 mysqld 1 command line: 2006-08-12 22:19:18 httpsd 19 mysqld 30 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
