業務場景:每天都有日誌而且每小時都有日誌,將日誌按照小時儲存
acccess_log/20190528/2019052800.log
2019052801.log
2019052802.log
#!/bin/bash
yesterday =
$(date -d "-1 days"+%y%m%d)
access_log_dir=/data/access_log/$yesterday
echo
$access_log_dir
#載入資料
for file in
$(ls $access_log_dir)
do# file = 2019052800.log
day=
$ hour=
$$hive_home/bin/hive -e "load data local inpath '$access_log_dir/$file' into table web_log partition(day='$day',hour='$hour');"
done
$hive_home/bin/hive 這個shell 命令是通向包括命令列介面(cli)等hive服務的通道。
-e 不進入hive,而去執行hive命令
day=$ file從第零位開始擷取,擷取長度為8的字元,並將此變數賦給day
$用於變數替換。一般情況下,$var 與$ 並沒有啥不一樣。但是用 $ 會比較精確的界定變數名稱的範圍
在 bash shell 中,$( ) 與` ` (反引號) 都是用來做命令替換用(commandsubstitution)的。
Hive shell指令碼形式執行HSQL
接上文mac 單機hive安裝與測試,文中最後將本地檔案load到了hive 表中,下面對該錶清洗,以shell指令碼形式提交,清洗所用的hsql指令碼。例如要清洗出的字段如下表 use hive test create external table fact log time stamp stri...
嵌入式中,自動載入sd卡指令碼
在 linux的嵌入式系統中,開機自動載入sd卡 這裡要用到mdev命令 其具體操作如下 1 首先在 etc init.d rsc中加入以下語句 echo sbin mdev proc sys kernel hotplug 2 在 etc 下建立medv.conf的檔案,包含以下內容 sd a z ...
載入執行多個自動化測試指令碼
import unittest import re import htmltestrunner 載入測試檔案 針對方法一 import testf1 testf1表示testf1.py檔案 import testf2 方法一 構造測試集 suit unittest.testsuite suit.ad...