Page 1 of 1
Crontab Entry
Posted:
Tue Mar 11, 2008 9:52 am
by CALLINGUSA
Hello,
I am facing problem of call getting stuck in vicidial_auto_calls table, i see all the calls with status as XFER, so from last few days, we write down one query after every 30 minutes or so, as follows:
delete from vicidial_auto_calls where status = XFER;
But now, we want to automate this, so i just copied the content of AST_reset_mysql_vars.pl, gave my query there and created one more file under /usr/share/astguiclient itself, by the name AST_reset_mysql_XFER.pl and gave it the right permission to be executable, like that of other files, but now when i am running this file, i get an error saying:
: bad interpreter: No such file or directoryql_XFER.pl: /usr/bin/perl
Can anyone guide me in right direction, on where else to do the entry to make this entry of crontab working, so that we don't have to write down the query manually every now and then.....
Posted:
Tue Mar 11, 2008 10:36 am
by gardo
What's your crontab entry for the script? Try running it like this:
30 * * * * * perl /usr/share/astguiclient itself, by the name AST_reset_mysql_XFER.pl
Posted:
Tue Mar 11, 2008 11:16 am
by CALLINGUSA
Thats not working.
and even when i am trying to run
/usr/share/astguiclient/AST_reset_mysql_XFER.pl
Directly from the root terminal, then also i am getting the same error:
: bad interpreter: No such file or directoryql_XFER.pl: /usr/bin/perl
Posted:
Tue Mar 11, 2008 12:29 pm
by Op3r
what version of vicidial are you using?
are you sure you have the perl dependencies installed?
Did you run install.pl?
Posted:
Tue Mar 11, 2008 1:01 pm
by CALLINGUSA
I am using 2.0.4, latest version.
Moreover i installed all the dependancies, i am able to run all other crontab entries, only this one is not running, which i just copied myself, this was a separate entry, here is the file:
#!/usr/bin/perl
#
# AST_reset_mysql_vars.pl version 0.3 *DBI-version*
#
# !!! DO NOT RUN THIS WHILE THERE ARE ACTIVE CALLS ON THE ASTERISK SERVER !!!
#
# DESCRIPTION:
# clears out mysql records for this server
#
# It is recommended that you run this program on the local Asterisk machine
#
# Copyright (C) 2006 MF <vicidial@gmail.com> LICENSE: GPLv2
#
# CHANGES
# 60717-1237 - changed to DBI by Marin Blu
# 60717-1536 - changed to use /etc/astguiclient.conf for configs
#
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
@conf = <conf>;
close(conf);
$i=0;
foreach(@conf)
{
$line = $conf[$i];
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
$i++;
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
use DBI;
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
$stmtA = "DELETE from vicidial_auto_calls where server_ip='$server_ip' and status = 'XFER';";
if($DB){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
print " - XFER Taken care of \n";
$dbhA->disconnect();
exit;
Posted:
Tue Mar 11, 2008 1:09 pm
by CALLINGUSA
When i go manually to the folder, and write down the command:
root@phone:/usr/share/astguiclient# perl AST_reset_mysql_XFER.pl
- XFER Taken care of
It works perfectly, where as when i try to run the perl file, like i can do other files it gives me an error, here are the stats:
root@phone:/usr/share/astguiclient# /usr/share/astguiclient/AST_reset_mysql_XFER.pl
: bad interpreter: No such file or directoryql_XFER.pl: /usr/bin/perl
Posted:
Wed Mar 12, 2008 5:36 am
by gardo
That's why you need to put an entry like this in your crontab:
30 * * * * * perl /usr/share/astguiclient itself, by the name AST_reset_mysql_XFER.pl
See the highlighted "perl" command before your perl script. Check my first post. The error you're getting has something to do with the text editor you're using to write the perl script.