Shell

作者: LeonTung | 来源:发表于2020-09-10 15:07 被阅读0次

时间命令

`date -d "2020-9-10" +%s` # 将时间转化为数值用于比较
start_day=`date -d "2020-09-01 +7 day" +%Y%m%d` # 日期按步长递增并格式化
echo "now: " `date "+%Y-%m-%d %H:%M:%S"`  # 打印当前时间

循环作业

#!/bin/bash

echo -e "\nbegin..."
start_day=2019-05-25 # 开始日期
end_day=2019-06-01  # 结束日期
step=7 #日期步长

while [ `date -d "$start_day" +%s` -le `date -d "$end_day" +%s` ] # 开始日期小于等于结束日期
do
    dt=`date -d "$start_day" +%Y%m%d`
    echo -e "\ndt=$dt"
    hive -e"
        set hive.execution.engine=tez;
        set tez.queue.name=root.label;
        -- your sql
        insert overwrite table dm.dm_test_leon partition(dt=$dt)
        select $dt, 1;
    "
    start_day=`date -d "$start_day +$step day" +%Y-%m-%d` # 调度日期按步长递增
done
echo -e "\nend with dt=$dt"

#!/bin/bash
 
params=$1
for param in $params
do
  echo $param
done

#运行方式为:
sh tt.sh "1 2 3 4 5"

相关文章

  • Shell 学习

    shell 变量 shell 参数传递 shell 数组 shell 运算符 shell echo 命令 prin...

  • Shell 概述

    学习 Shell 主要包括的内容: Shell 脚本入门 Shell 变量 Shell 内置命令 Shell 运算...

  • Shell 教程

    Shell 变量 Shell 传递参数 Shell 数组 Shell 基本运算符 Shell echo 命令 Sh...

  • shell 第一天

    shell编程初识 1.1 shell编程初识 shell的定义 Shell 是命令解释器 Shell 也是...

  • shell 案例

    Shell编程一 Shell防范ARP攻击 Shell编程二 Shell防范DDos攻击 Shell编程三 ...

  • 【生物信息笔记】shell 脚本 (dry-2)

    shell 和 shell script(脚本)区别: shell 和 shell 脚本是两个不同概念,shell...

  • Linux Shell:基础知识和Shell变量

    摘要:Linux,Shell 整理Shell内容要点: Shell基础知识 Shell变量的类型 Shell变量赋...

  • Shell脚本语言一

    一、语法 格式 运行 Shell变量 Shell字符串 Shell数组 Shell注释 Shell传递参数 She...

  • 使用shell脚本

    使用方式 shell 变量 shell 字符串操作 shell 数组 shell 注释 shell 命令行参数 s...

  • vim学习 09——shell命令

    vim学习 09——shell命令 执行 shell 命令 :!shell命令 : 可以执行 shell 命令。 ...

网友评论

      本文标题:Shell

      本文链接:https://www.haomeiwen.com/subject/bjlpektx.html