#!/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