一些shell脚本

tech2024-06-07  77

未完结单据:

#!/bin/bash # 未完结单据库存自动对比脚本 # Author: nielixiang # Date: 2020-09-03 # 读取目标微仓列表 file=/home/rd/inventory-fix/warehouse_list.file warehouseIds=$(cat $file) echo "目标微仓列表:$warehouseIds" # 切到脚本所在的目录并执行命令 if [[ $warehouseIds = "" ]]; then echo "未发现需要对比的微仓列表,不用执行对比脚本" else cd /home/rd/inventory-fix/mtools/mtools-dist/target/sc-tools-dist-1.0.0-SNAPSHOT-bin/sc-tools-dist-1.0.0-SNAPSHOT-bin/bin ./mtools-inventory.sh InventoryInit --compare $warehouseIds echo "未完结单据对比命令执行完成" fi

出入库单对比:

#!/bin/bash # 出入库单对比命令,本脚本仅比较微仓ID最后一个数字%3=0的微仓,如120、123、3、276等 # Author: nielixiang # Date: 2020-09-03 #读取目标微仓列表 file=/home/rd/inventory-fix/warehouse_list.file allWarehouseIds=$(cat $file) targetWarehouseIds="" warehouseIdArr=(${allWarehouseIds//,/ }) for warehouseId in ${warehouseIdArr[@]} do lastChar=${warehouseId: -1} ret=$(($lastChar % 3)) if [[ $ret = 0 ]]; then targetWarehouseIds=${targetWarehouseIds}${warehouseId}"," fi done targetWarehouseIds=${targetWarehouseIds%?} echo "最终得到的微仓列表:$targetWarehouseIds" #切换到命令目录并执行出入库单对比命令 if [[ $targetWarehouseIds = "" ]]; then echo "未发现需要对比的微仓列表,不用执行对比脚本" else cd /home/rd/inventory-fix/mtools/mtools-dist/target/sc-tools-dist-1.0.0-SNAPSHOT-bin/sc-tools-dist-1.0.0-SNAPSHOT-bin/bin compareEndTime=$(date +'%Y-%m-%d%H:%M:%S' -d '-5 seconds') compareStartTime=$(date +'%Y-%m-%d%H:%M:%S' -d '-1 day -5 seconds') ./mtools-inventory.sh BusinessInOutCheck --subWarehouseIds $targetWarehouseIds --startTime $compareStartTime --endTime $compareEndTime echo "出入库单对比命令执行完成" fi

crontab:

*/1 * * * * sh -c 'source /etc/profile;sh /home/rd/inventory-fix/shells/compare_unfinish.sh' >> /home/rd/inventory-fix/shells/crontab.log 2>&1

 

最新回复(0)