shell 操作 MySQL

#!/bin/bash
MYSQL=`which mysql`
MYSQL_USER=root
MYSQL_PASSWORD=12345
SCRIPT_PATH=/home/li/WebDoc/backend/beanstalk-job/cli.php

read startDate < <($MYSQL addata -u$MYSQL_USER -p$MYSQL_PASSWORD -N -e "SELECT max(date) as startDate FROM ad_region_device_report")
#或者 startDate="$($MYSQL addata -u$MYSQL_USER -p$MYSQL_PASSWORD -N -e "SELECT max(date) as startDate FROM ad_region_device_report")"

if [ $startDate == "NULL" ]; then
  echo "Error"
else
  php $SCRIPT_PATH RegionDeviceReport main $startDate
fi

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

4 × 1 =