Crontab Entry

All installation and configuration problems and questions

Moderators: gerski, enjay, williamconley, Op3r, Staydog, gardo, mflorell, MJCoate, mcargile, Kumba, Michael_N

Crontab Entry

Postby CALLINGUSA » Tue Mar 11, 2008 9:52 am

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.....
CALLINGUSA
 
Posts: 27
Joined: Fri Nov 30, 2007 2:02 pm

Postby gardo » Tue Mar 11, 2008 10:36 am

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
http://goautodial.com
Empowering the next generation contact centers
gardo
 
Posts: 1926
Joined: Fri Sep 15, 2006 10:24 am
Location: Manila, 1004

Postby CALLINGUSA » Tue Mar 11, 2008 11:16 am

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
CALLINGUSA
 
Posts: 27
Joined: Fri Nov 30, 2007 2:02 pm

Postby Op3r » Tue Mar 11, 2008 12:29 pm

what version of vicidial are you using?

are you sure you have the perl dependencies installed?

Did you run install.pl?
Get paid for US outbound Toll Free calls. PM me.
Op3r
 
Posts: 1432
Joined: Wed Jun 07, 2006 7:53 pm
Location: Manila

Postby CALLINGUSA » Tue Mar 11, 2008 1:01 pm

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;
CALLINGUSA
 
Posts: 27
Joined: Fri Nov 30, 2007 2:02 pm

Postby CALLINGUSA » Tue Mar 11, 2008 1:09 pm

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
CALLINGUSA
 
Posts: 27
Joined: Fri Nov 30, 2007 2:02 pm

Postby gardo » Wed Mar 12, 2008 5:36 am

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.
http://goautodial.com
Empowering the next generation contact centers
gardo
 
Posts: 1926
Joined: Fri Sep 15, 2006 10:24 am
Location: Manila, 1004


Return to Support

Who is online

Users browsing this forum: Google [Bot] and 103 guests