bonjour. je suis sur un serveur linux fedora 6, mysql-5.0.27-1, apache 2.2.3-5, php-5.1.6-3. quand je lance les script suivants, voici les erreurs en sortie:
voici l'erreur#!/bin/sh -x
SQLUSER="xxxx"
SQLPASS="yyyy"
SQLBASE="proxy"
SQLCMD="mysql -u$SQLUSER -p$SQLPASS $SQLBASE"
TBLEXT="date --date=yesterday +%Y%m"
#################################################
#########Fonctions d'archivage
#################################################
function create_proxyaccess () {
if [ -z $($SQLCMD -ss -e "SHOW tables like 'proxyaccess$TBLEXT'") ]; then
echo creation de la table proxydenied$TBLEXT
$SQLCMD -e "CREATE TABLE proxyaccess$TBLEXT (date datetime NOT NULL,proxy char(6) NOT NULL,user char(25) NOT NULL,IP char(15) NOT NULL,fqdn char(64) NOT NULL,url text NOT NULL,http_status int(11) NOT NULL,squid_status char(25) NOT NULL,method char(8) NOT NULL,reqtime int(11) NOT NULL,taille int(11) NOT NULL) ENGINE=ARCHIVE DEFAULT CHARSET=latin1"
fi
}
function archive_proxyaccess () {
echo archivage des logs du proxy \(proxyaccess$TBLEXT\)
create_proxyaccess
$SQLCMD -e "insert into proxyaccess$TBLEXT select * from proxyaccess where date < date_format(now(),'%Y-%m-%d');delete from proxyaccess where date < date_format(now(),'%Y-%m-%d');optimize table proxyaccess;"
}
function create_proxydenied () {
if [ -z $($SQLCMD -ss -e "SHOW tables like 'proxydenied$TBLEXT'") ]; then
echo creation de la table proxydenied$TBLEXT
$SQLCMD -e "CREATE TABLE proxydenied$TBLEXT (date datetime NOT NULL,proxy char(6) NOT NULL,user char(25) NOT NULL,IP char(15) NOT NULL,fqdn char(64) NOT NULL,url text NOT NULL,http_status int(11) NOT NULL,squid_status char(25) NOT NULL,method char(8) NOT NULL,reqtime int(11) NOT NULL,taille int(11) NOT NULL) ENGINE=ARCHIVE DEFAULT CHARSET=latin1"
fi
}
function archive_proxydenied () {
echo archivage des logs du proxy \(proxydenied$TBLEXT\)
create_proxydenied
$SQLCMD -e "insert into proxydenied$TBLEXT select * from proxydenied where date < date_format(now(),'%Y-%m-%d');delete from proxydenied where date < date_format(now(),'%Y-%m-%d');optimize table proxydenied;"
}
function archive () {
archive_proxyaccess
archive_proxydenied
}
#############################################
#########Functions de statistiques
#############################################
function set_mode () {
if [ 'date +%d' = "01" ]; then
STATMOIS="1"
else
STATMOIS="0"
fi
if [ 'date +%w' = "1" ]; then
STATSEM="1"
else
STATSEM="0"
fi
}
function stats() {
set_mode
stat_mois
stat_semaine
stat_jour
}
###########################################
##########Programme principal
###########################################
archive
voici le 2e scriptarchivage des logs du proxy (proxyaccessdate --date=yesterday +%Y%m)
creation de la table proxydenieddate --date=yesterday +%Y%m
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m (date datetime NOT NULL,proxy char(6) NOT NULL,user char(' at line 1
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m select * from proxyaccess where date < date_format(now(),' at line 1
archivage des logs du proxy (proxydenieddate --date=yesterday +%Y%m)
creation de la table proxydenieddate --date=yesterday +%Y%m
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m (date datetime NOT NULL,proxy char(6) NOT NULL,user char(' at line 1
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m select * from proxydenied where date < date_format(now(),' at line 1
Voici l'erreur#!/bin/sh
SQLUSER="xxxx"
SQLPASS="yyyy"
SQLBASE="httpd"
SQLCMD="mysql -u$SQLUSER -p$SQLPASS $SQLBASE"
TBLEXT='date --date=yesterday +%Y%m'
#########################################
#########Fonctions d'archivage
#########################################
function create_httpaccess () {
if [ -z $($SQLCMD -ss -e "SHOW tables like 'httpaccess$TBLEXT'") ]; then
echo creation de la table httpdaccess$TBLEXT
$SQLCMD -e "CREATE TABLE httpaccess$TBLEXT (date datetime NOT NULL,srv char(10) NOT NULL,vhost char(64) NOT NULL,user char(25) NOT NULL,IP char(15) NOT NULL,fqdn char(64) NOT NULL,url text NOT NULL,http_status int(11) NOT NULL,method char(8) NOT NULL,taille int(11) NOT NULL,user_agent text NOT NULL) ENGINE=ARCHIVE DEFAULT CHARSET=latin1"
fi
}
function archive_httpaccess () {
echo archivage des logs de httpd \(httpaccess$TBLEXT\)
create_httpaccess
echo deplacement des donnees vers httpaccess$TBLEXT
$SQLCMD -e "insert into httpaccess$TBLEXT select * from httpaccess where date < date_format(now(),'%Y-%m-%d');delete from httpaccess where date < date_format(now(),'%Y-%m-%d');optimize table httpaccess;"
}
function archive () {
archive_httpaccess
}
########################################
#########Programme principal
########################################
archive
qlq'1 peut-il m'aider svp. c vraiment urgent.archivage des logs de httpd (httpaccessdate --date=yesterday +%Y%m)
creation de la table httpdaccessdate --date=yesterday +%Y%m
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m (date datetime NOT NULL,srv char(10) NOT NULL,vhost char(' at line 1
deplacement des donnees vers httpaccessdate --date=yesterday +%Y%m
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--date=yesterday +%Y%m select * from httpaccess where date < date_format(now(),'' at line 1
Merci.
Partager