Сообщение leon » 2016-05-01 12:57:29
scripts/billing/check.cron.run.sh
Код: Выделить всё
root@localhost:/var/www/clients/client0/web30/web# sh -xv scripts/billing/check.cron.run.sh
#!/bin/sh
# $1 - /path/to/php.ini
# $2 - /path/to/php
# $3 - billing.hostname.su
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
TMPDIR="${TMPDIR:="/tmp"}"
+ TMPDIR=/tmp
TmpFile="$TMPDIR/jbs.$$.txt"
+ TmpFile=/tmp/jbs.28365.txt
# проверяем что запись во временный файл возможна
if ! echo -n > $TmpFile >/dev/null 2>&1
then
echo "cannot create tmp file = $TmpFile"
exit 1;
fi
+ echo -n
#find php
if test -x "$2" -a -f "$2"
then
echo $2 > $TmpFile
else
for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
do
test -x $cli && echo $cli > $TmpFile
done
fi
+ test -x '' -a -f ''
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/bin/php
+ echo /usr/bin/php
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/local/bin/php
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/bin/php-cgi
+ echo /usr/bin/php-cgi
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/local/bin/php-cgi
#------------------------------------------------
if ! test -s $TmpFile
then
echo "cannot find php interpretator"
echo 1;
fi
+ test -s /tmp/jbs.28365.txt
#------------------------------------------------
if test -f "$1"
then
export PHP_BIN="`cat $TmpFile` -c $1"
else
export PHP_BIN="`cat $TmpFile`"
fi
+ test -f ''
cat $TmpFile
++ cat /tmp/jbs.28365.txt
+ export PHP_BIN=/usr/bin/php-cgi
+ PHP_BIN=/usr/bin/php-cgi
rm -f $TmpFile
+ rm -f /tmp/jbs.28365.txt
#------------------------------------------------
# топаем в директорию со скриптами
ScriptsDir="`dirname $0`"
dirname $0
++ dirname scripts/billing/check.cron.run.sh
+ ScriptsDir=scripts/billing
if ! cd $ScriptsDir
then
echo "cannot change dir to $ScriptsDir"
exit 1;
fi
+ cd scripts/billing
ScriptsDir="`pwd`"
pwd
++ pwd
+ ScriptsDir=/var/www/clients/client0/web30/web/scripts/billing
#------------------------------------------------
if test -n "$3"
then
echo "$3" > $TmpFile
else
# ищщем host.ini
for dir in ../../hosts/*
do
if test -f $dir/host.ini
then
eval `cat $dir/host.ini | grep 'HostsIDs=' | awk -F ',' '{print $1}' | tr -d '"' `
echo $HostsIDs > $TmpFile
fi
done
fi
+ test -n ''
+ for dir in '../../hosts/*'
+ test -f ../../hosts/billing/host.ini
+ for dir in '../../hosts/*'
+ test -f ../../hosts/billing.********.ru/host.ini
cat $dir/host.ini | grep 'HostsIDs=' | awk -F ',' '{print $1}' | tr -d '"'
++ awk -F , '{print $1}'
++ tr -d '"'
++ grep HostsIDs=
++ cat ../../hosts/billing.********.ru/host.ini
+ eval HostsIDs=billing.********.ru
HostsIDs=billing.********.ru
++ HostsIDs=billing.********.ru
+ echo billing.********.ru
+ for dir in '../../hosts/*'
+ test -f ../../hosts/hosting/host.ini
+ for dir in '../../hosts/*'
+ test -f ../../hosts/joonte/host.ini
cat $dir/host.ini | grep 'HostsIDs=' | awk -F ',' '{print $1}' | tr -d '"'
++ cat ../../hosts/joonte/host.ini
++ awk -F , '{print $1}'
++ tr -d '"'
++ grep HostsIDs=
+ eval
+ echo billing.********.ru
+ for dir in '../../hosts/*'
+ test -f ../../hosts/license/host.ini
+ for dir in '../../hosts/*'
+ test -f ../../hosts/root/host.ini
#------------------------------------------------
if ! test -s $TmpFile
then
echo "cannot find billing hostname"
exit 1;
else
HostsID=`cat $TmpFile`
rm -f $TmpFile
fi
+ test -s /tmp/jbs.28365.txt
cat $TmpFile
++ cat /tmp/jbs.28365.txt
+ HostsID=billing.********.ru
+ rm -f /tmp/jbs.28365.txt
#------------------------------------------------
# достаём корневую директорию биллинга
RootDir=`dirname $ScriptsDir`
dirname $ScriptsDir
++ dirname /var/www/clients/client0/web30/web/scripts/billing
+ RootDir=/var/www/clients/client0/web30/web/scripts
RootDir=`dirname $RootDir`
dirname $RootDir
++ dirname /var/www/clients/client0/web30/web/scripts
+ RootDir=/var/www/clients/client0/web30/web
#------------------------------------------------
#------------------------------------------------
marker="$RootDir/hosts/$HostsID/tmp/TaskLastExecute.txt"
+ marker=/var/www/clients/client0/web30/web/hosts/billing.********.ru/tmp/TaskLastExecute.txt
# проверяем, запущен скрипт или нет
if [ ! `ps auxww | grep "sh demon.sh $HostsID" | grep -v grep | wc -l` -gt 0 ]
then
rm -f $marker
# let Mortal Combat begin! =)
sh demon.sh $HostsID $RootDir >> $RootDir/demon.log &
chmod 600 $RootDir/demon.log
fi
ps auxww | grep "sh demon.sh $HostsID" | grep -v grep | wc -l
++ grep -v grep
++ ps auxww
++ wc -l
++ grep 'sh demon.sh billing.********.ru'
+ '[' '!' 0 -gt 0 ']'
+ rm -f /var/www/clients/client0/web30/web/hosts/billing.********.ru/tmp/TaskLastExecute.txt
+ chmod 600 /var/www/clients/client0/web30/web/demon.log
+ sh demon.sh billing.********.ru /var/www/clients/client0/web30/web
#------------------------------------------------
#------------------------------------------------
# проверяем, как давно выполнялось последнее задание
if test -f $marker
then
# определяем время на час назад, в разных системах по разному
if [ `uname` = "Linux" ]
then
now=`date --date='1 hour ago' +%Y%m%d%H%M%S`
else
now=`date -v-1H +%Y%m%d%H%M%S`
fi
if [ $now -ge `cat $marker` ]
then
echo "" >> $RootDir/demon.log
echo "`date +%Y-%m-%d` in `date +%H:%M:%S`: php-cgi auto killed, no executed tasks more than one hour" >> $RootDir/demon.log
echo "" >> $RootDir/demon.log
killall `basename $PHP_BIN`
fi
fi
+ test -f /var/www/clients/client0/web30/web/hosts/billing.********.ru/tmp/TaskLastExecute.txt
# delete tmp file
rm -f $TmpFile
+ rm -f /tmp/jbs.28365.txt
root@localhost:/var/www/clients/client0/web30/web# Failed loading /usr/local/lib/ioncube_loader_lin_5.4.so: /usr/local/lib/ioncube_loader_lin_5.4.so: cannot open shared object file: No such file or directory
Failed loading /usr/lib64/php/ioncube/ioncube_loader_lin_5.4.so: /usr/lib64/php/ioncube/ioncube_loader_lin_5.4.so: cannot open shared object file: No such file or directory
scripts/billing/check.cron.run.sh
[code]root@localhost:/var/www/clients/client0/web30/web# sh -xv scripts/billing/check.cron.run.sh
#!/bin/sh
# $1 - /path/to/php.ini
# $2 - /path/to/php
# $3 - billing.hostname.su
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
TMPDIR="${TMPDIR:="/tmp"}"
+ TMPDIR=/tmp
TmpFile="$TMPDIR/jbs.$$.txt"
+ TmpFile=/tmp/jbs.28365.txt
# проверяем что запись во временный файл возможна
if ! echo -n > $TmpFile >/dev/null 2>&1
then
echo "cannot create tmp file = $TmpFile"
exit 1;
fi
+ echo -n
#find php
if test -x "$2" -a -f "$2"
then
echo $2 > $TmpFile
else
for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
do
test -x $cli && echo $cli > $TmpFile
done
fi
+ test -x '' -a -f ''
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/bin/php
+ echo /usr/bin/php
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/local/bin/php
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/bin/php-cgi
+ echo /usr/bin/php-cgi
+ for cli in /usr/bin/php /usr/local/bin/php /usr/bin/php-cgi /usr/local/bin/php-cgi
+ test -x /usr/local/bin/php-cgi
#------------------------------------------------
if ! test -s $TmpFile
then
echo "cannot find php interpretator"
echo 1;
fi
+ test -s /tmp/jbs.28365.txt
#------------------------------------------------
if test -f "$1"
then
export PHP_BIN="`cat $TmpFile` -c $1"
else
export PHP_BIN="`cat $TmpFile`"
fi
+ test -f ''
cat $TmpFile
++ cat /tmp/jbs.28365.txt
+ export PHP_BIN=/usr/bin/php-cgi
+ PHP_BIN=/usr/bin/php-cgi
rm -f $TmpFile
+ rm -f /tmp/jbs.28365.txt
#------------------------------------------------
# топаем в директорию со скриптами
ScriptsDir="`dirname $0`"
dirname $0
++ dirname scripts/billing/check.cron.run.sh
+ ScriptsDir=scripts/billing
if ! cd $ScriptsDir
then
echo "cannot change dir to $ScriptsDir"
exit 1;
fi
+ cd scripts/billing
ScriptsDir="`pwd`"
pwd
++ pwd
+ ScriptsDir=/var/www/clients/client0/web30/web/scripts/billing
#------------------------------------------------
if test -n "$3"
then
echo "$3" > $TmpFile
else
# ищщем host.ini
for dir in ../../hosts/*
do
if test -f $dir/host.ini
then
eval `cat $dir/host.ini | grep 'HostsIDs=' | awk -F ',' '{print $1}' | tr -d '"' `
echo $HostsIDs > $TmpFile
fi
done
fi
+ test -n ''
+ for dir in '../../hosts/*'
+ test -f ../../hosts/billing/host.ini
+ for dir in '../../hosts/*'
+ test -f ../../hosts/billing.********.ru/host.ini
cat $dir/host.ini | grep 'HostsIDs=' | awk -F ',' '{print $1}' | tr -d '"'
++ awk -F , '{print $1}'
++ tr -d '"'
++ grep HostsIDs=
++ cat ../../hosts/billing.********.ru/host.ini
+ eval HostsIDs=billing.********.ru
HostsIDs=billing.********.ru
++ HostsIDs=billing.********.ru
+ echo billing.********.ru
+ for dir in '../../hosts/*'
+ test -f ../../hosts/hosting/host.ini
+ for dir in '../../hosts/*'
+ test -f ../../hosts/joonte/host.ini
cat $dir/host.ini | grep 'HostsIDs=' | awk -F ',' '{print $1}' | tr -d '"'
++ cat ../../hosts/joonte/host.ini
++ awk -F , '{print $1}'
++ tr -d '"'
++ grep HostsIDs=
+ eval
+ echo billing.********.ru
+ for dir in '../../hosts/*'
+ test -f ../../hosts/license/host.ini
+ for dir in '../../hosts/*'
+ test -f ../../hosts/root/host.ini
#------------------------------------------------
if ! test -s $TmpFile
then
echo "cannot find billing hostname"
exit 1;
else
HostsID=`cat $TmpFile`
rm -f $TmpFile
fi
+ test -s /tmp/jbs.28365.txt
cat $TmpFile
++ cat /tmp/jbs.28365.txt
+ HostsID=billing.********.ru
+ rm -f /tmp/jbs.28365.txt
#------------------------------------------------
# достаём корневую директорию биллинга
RootDir=`dirname $ScriptsDir`
dirname $ScriptsDir
++ dirname /var/www/clients/client0/web30/web/scripts/billing
+ RootDir=/var/www/clients/client0/web30/web/scripts
RootDir=`dirname $RootDir`
dirname $RootDir
++ dirname /var/www/clients/client0/web30/web/scripts
+ RootDir=/var/www/clients/client0/web30/web
#------------------------------------------------
#------------------------------------------------
marker="$RootDir/hosts/$HostsID/tmp/TaskLastExecute.txt"
+ marker=/var/www/clients/client0/web30/web/hosts/billing.********.ru/tmp/TaskLastExecute.txt
# проверяем, запущен скрипт или нет
if [ ! `ps auxww | grep "sh demon.sh $HostsID" | grep -v grep | wc -l` -gt 0 ]
then
rm -f $marker
# let Mortal Combat begin! =)
sh demon.sh $HostsID $RootDir >> $RootDir/demon.log &
chmod 600 $RootDir/demon.log
fi
ps auxww | grep "sh demon.sh $HostsID" | grep -v grep | wc -l
++ grep -v grep
++ ps auxww
++ wc -l
++ grep 'sh demon.sh billing.********.ru'
+ '[' '!' 0 -gt 0 ']'
+ rm -f /var/www/clients/client0/web30/web/hosts/billing.********.ru/tmp/TaskLastExecute.txt
+ chmod 600 /var/www/clients/client0/web30/web/demon.log
+ sh demon.sh billing.********.ru /var/www/clients/client0/web30/web
#------------------------------------------------
#------------------------------------------------
# проверяем, как давно выполнялось последнее задание
if test -f $marker
then
# определяем время на час назад, в разных системах по разному
if [ `uname` = "Linux" ]
then
now=`date --date='1 hour ago' +%Y%m%d%H%M%S`
else
now=`date -v-1H +%Y%m%d%H%M%S`
fi
if [ $now -ge `cat $marker` ]
then
echo "" >> $RootDir/demon.log
echo "`date +%Y-%m-%d` in `date +%H:%M:%S`: php-cgi auto killed, no executed tasks more than one hour" >> $RootDir/demon.log
echo "" >> $RootDir/demon.log
killall `basename $PHP_BIN`
fi
fi
+ test -f /var/www/clients/client0/web30/web/hosts/billing.********.ru/tmp/TaskLastExecute.txt
# delete tmp file
rm -f $TmpFile
+ rm -f /tmp/jbs.28365.txt
root@localhost:/var/www/clients/client0/web30/web# Failed loading /usr/local/lib/ioncube_loader_lin_5.4.so: /usr/local/lib/ioncube_loader_lin_5.4.so: cannot open shared object file: No such file or directory
Failed loading /usr/lib64/php/ioncube/ioncube_loader_lin_5.4.so: /usr/lib64/php/ioncube/ioncube_loader_lin_5.4.so: cannot open shared object file: No such file or directory[/code]