[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/usr/share/se3/sbin/ -> clean_session_mysql.sh (source)

   1  #!/bin/bash
   2  #
   3  # Franck Molle
   4  # distribue sous licence GPL
   5  # 12/2005
   6  #
   7  ##### Permet de vider la table session et delester connexions de se3db afin d'eviter le debordement, script lancé une fois / mois par cron #####
   8  ##$Id: clean_session_mysql.sh 7723 2013-03-18 23:57:26Z keyser $##
   9  #
  10  
  11  if [ "$1" = "--help" -o "$1" = "-h" ]
  12  then
  13      echo "permet de vider la table session  et nettoyer la table connexions de la base mysql se3bd"
  14      echo "Ce script est lance une fois par mois en crontab /etc/crontab.monthly"
  15      echo ""
  16      echo "Usage : aucune option"
  17      exit
  18  fi    
  19  
  20  
  21  
  22  
  23  
  24  WWWPATH="/var/www"
  25  echo -e "$COLCMD\c"
  26  if [ -e $WWWPATH/se3/includes/config.inc.php ]; then
  27      dbhost=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbhost=" | cut -d = -f 2 |cut -d \" -f 2`
  28      dbname=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbname=" | cut -d = -f 2 |cut -d \" -f 2`
  29      dbuser=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbuser=" | cut -d = -f 2 |cut -d \" -f 2`
  30      dbpass=`cat $WWWPATH/se3/includes/config.inc.php | grep "dbpass=" | cut -d = -f 2 |cut -d \" -f 2`
  31  else
  32      echo -e "$COLERREUR"
  33      echo "Fichier de conf inaccessible."
  34      echo -e "$COLTXT"
  35      exit 1
  36  fi
  37  ## vidage de la table session
  38  echo "Vidage de la table session"
  39  echo "TRUNCATE sessions"|mysql -h $dbhost $dbname -u $dbuser -p$dbpass
  40  
  41  echo "delestage de la table connexions"
  42  echo "delete from connexions where logintime<date_sub(now(),INTERVAL 90 DAY)"|mysql -h $dbhost $dbname -u $dbuser -p$dbpass
  43  
  44  exit 0


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1