标签:
#!/bin/bash #Please Input start date eg:2016-01-01 and enddate eg:2016-01-20 #IF START DATE IS NULL THEN START DATE EQUAL 2016-01-01 #IF END DATE IS NULL THEN END DATE DEFAULT IS ‘1 DAY AGO‘ if [ "$1" != "" ];then startday=`date -d "$1" +%Y-%m-%d` else startday=‘2016-01-01‘ fi if [ "$2" != "" ];then endday=`date -d "$2" +%Y-%m-%d` else endday=`date -d "1 days ago" +%Y-%m-%d` fi tempstartday=`date -d "-0 day $startday" +%F` startdaysec=`date -d "-0 day $startday" +%s` enddaysec=`date -d "-0 day $endday" +%s` cd /home/hive for i in `seq 1 300`; do if [[ $startdaysec -gt $enddaysec ]]; then break fi #exec python shell /usr/bin/python /home/hive/xx.py ${tempstartday} tempstartday=`date -d "$i day $startday" +%F` startdaysec=`date -d "$i day $startday" +%s` done
运行shell
sh demo.sh ‘2016-01-01‘ ‘2016-01-20‘
linux shell 运行指定日期区间内的 python脚本
标签:
原文地址:http://www.cnblogs.com/liutizhong/p/5144683.html