DaemonForums  

Go Back   DaemonForums > FreeBSD > FreeBSD General

FreeBSD General Other questions regarding FreeBSD which do not fit in any of the categories below.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 16th August 2008
ivanatora ivanatora is offline
Real Name: Ivan
Fdisk Soldier
 
Join Date: Jul 2008
Location: Bulgaria
Posts: 51
Thanked 2 Times in 1 Post
Default Cron won't execute a perl script

I've set up a little script, written in Perl that keeps stats of ping timeous. I want to schedule it to run every 5 minutes.
This is my crontab:
Code:
*/5 * * * * /usr/bin/perl /home/ivanatora/dev/ping_stats.pl > /home/ivanatora/cronlog
You can see that I've even added the full path to the perl interpreter in case of $PATH misunderstandings...
And here is the script:
Code:
> cat ping_stats.pl
#!/usr/bin/perl
$dump = "/home/ivanatora/stats_ping_packet_loss.log";
open (FH, ">>", $dump) or die "$!";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$mon++;
$year += 1900;
$time = sprintf("%02d/%02d/%4d %02d:%02d:%02d", $mday, $mon, $year, $hour, $min, $sec);
$output = `ping -q -c200 xx.xxx.xxx.xxx`;

if ($output =~ /(\d+?)% packet loss/){
        print FH "$time : $1% loss\n";
        print "$time : $1% loss\n";

}
close (FH);
If I run the script from command line it works. However cron appears to 'run' it, but nothing happened. I'm tracking the process list with `ps` and I shuld see the 'ping' process for a long time, but there is nothing. Also the output file is not written at all, nor the stdout pipe.

I see this in /var/log/cron:
Code:
Aug 16 15:05:00 jupiter /usr/sbin/cron[1535]: (ivanatora) CMD (/usr/bin/perl /home/ivanatora/dev/ping_stats.pl > /home/ivanatora/cronlog)
What does that mean? It says it had run it, but nothing?

I'm about to say again that the script is working if run manualy, or even working in Linux crontab.
What am I doing wrong in FreeBSD?
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"free" command/perl script for freebsd unixdude FreeBSD General 0 17th November 2008 09:23 PM
execute commands from xinitrc rex FreeBSD General 3 22nd October 2008 10:24 PM
Execute a command during login rex FreeBSD General 4 12th September 2008 08:09 PM
Cronjob script does not run in cron godfrank FreeBSD General 9 30th June 2008 12:41 AM
Perl Script c0mrade Programming 1 26th June 2008 05:04 AM


All times are GMT. The time now is 06:25 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick