
dzordzyk
Novice
Mar 13, 2010, 11:38 AM
Post #1 of 21
(1285 views)
|
|
Executing script from cron.d
|
Can't Post
|
|
Hello, I've weird problem. Script running from console (sudo perl check_service) works fine but from cron.d doesn't work. Script is: 1 #!/usr/bin/perl 2 3 # 4 # Konfiguracja w pliku check_service.conf 5 # 6 # 7 8 use warnings; 9 use strict; 10 use lib '/root/'; 11 use Common; 12 13 open my $config, "<", "/root/tests/check_service.conf" or die "Can not read check_service.conf: $!"; 14 15 while (my $line = <$config>) { 16 chomp ($line); 17 18 next if $line =~ /^\s*#/; # komentarz 19 next if $line =~ /^\s*$/; # pusta linia 20 21 my $service = $line; 22 23 my $ps_output = `ps ax | grep "$service" | grep -v $0 | grep -v grep`; 24 if ($ps_output eq "") { # nie ma usÅ~Bugi 25 print "$service IS NOT WORKING\n"; 26 Common::alert_sms($service); 27 Common::alert_mail("$service\@$Common::hostname IS NOT WORKING", "$service\@$Common::hostname IS NOT WORKING"); 30 } 31 else { 32 print "$service is working\n"; 33 } 34 35 } Script check, if process is alive. If yes - nothing do. If no - send me email and sms. In cron i've: */1 * * * * root perl /root/tests/check_service So - running from console works fine, but from cron.d no. Interesting is, on another server, scripts from cron.d works fine! I don't know, what is wrong. In cron.log i see script is running ok Thanks for reply Regards, dzordzyk
|