shell backup

shell backup




Test shell

# / Bin / Bash!
Echo Shell Start

# input parameters: URL
Api_url = $ 1

# input parameters drunk URL generation
Rootpath = Http: //10.19.69.50: 8080 / Test
Tokenid = S3TZLVN5MSKF5wi17KwC

Echo $ 1
Echo "$ 1"

If [ "$ 1" == "DoukikaOnlyDiff"]
Then
Api_url = $ Rootpath / Batch / Evaluation / Execute / 1? TokenId = $ Tokenid
Else
Api_url = $ 1
Fi

Echo "Api_url = $ Api_url"

Echo Shell End







Call of the API

# / Bin / Bash!
Echo Shell Start

# log of the path
Log_dir = / Sb / Logs / Kwc / Scripts

If [-D $ Log_dir!]; Then
Mkdir -P $ Log_dir
Fi

# log of the full path
path_log = $ log_dir / official_faq_callApi_` Date 'Tasu Pasento Y Pasento M Pasento D' `.Log

# input parameters: URL
Api_url = $ 1

# input parameters drunk URL generation
Rootpath = Http: //10.157.99.52: 8080 / batch
Tokenid = S3TZLVN5MSKF5wi17KwC

# Case1, content evaluation batch
if [ "$ 1" == "Evaluation_execute"]; Then
? Api_url = $ Rootpath / FaqAPI / batch / Evaluation / Execute / 1 TokenId = $ Tokenid
Fi
# Case2, I maintenance batch (one or more years of feedback data deletion process) say
if [ "$ 1" == "delete1yBefore "]; then
api_url=$rootpath/batch/Feedback/delete1yBefore/1?tokenId=$tokenid
fi
# case3、DFSデータ同期化(未同期化部分だけ同期化する)
if [ "$1" == "doukikaOnlyDiff" ]; then
api_url=$rootpath/batch/dfs/doukikaOnlyDiff/1?tokenId=$tokenid
fi
echo "api_url=$api_url"

# 実行結果判断用
result_code="resultCd"

echo -e 【`date +"%Y/%m/%d %H:%M:%S"`】 "********************************************** 処理開始 **********************************************" >>$path_log 2>&1
echo -e "api_url=$api_url" >> $path_log 2>&1

if [ ! -n "$api_url" ]; then
echo url not null
echo -e "url not null" >> $path_log
else
#get http response
echo "URL=$api_url"
http_result=$(curl -s $api_url)
echo -e "$http_result" >> $path_log
if [[ $http_result =~ $result_code ]]
then
result_code=${http_result:13:1}
if [ $result_code -eq 0 ]; then
echo Execute sucess
echo -e Execute sucess >> $path_log
else
echo Execute failed
echo -e Execute failed >> $path_log
fi
else
echo URL is wrong
echo -e 入力パラメータURL不正 >> $path_log
fi
fi

echo -e 【`date "+%Y/%m/%d %H:%M:%S"`】 "********************************************** 処理終了 **********************************************" >>$path_log 2>&1
echo shell end




For deletion

# / Bin / Bash!

##### Define Field
Shell_name = Official_faq_intelligentsearch_postCapture.Sh

# log of the path
Log_dir = / Sb / Logs / Kwc / Scripts

If [-D $ Log_dir!]; Then
Mkdir -P $ Log_dir
Fi

# log of full path
Log_file = $ Log_dir / Official_faq_intelligentsearch_postCapture_`date 'Tasu Pasento Y Pasento M Pasento D' `.Log

# working directory
Target_dir = / Sb / Logs / IntelligentSearch

# target file
Target_file = $ Target_dir / IntelligentSearch-Is.Log

Echo [` date "+% Y /% m / % d% H:% M:% S" ` ] ***************************** ***************** processing start ******************************* >> $ Log_file *************** 2> Ando 1

# if the target file exists, delete
if [-f $ target_file]; then
echo "Delete work start" >> $ Log_file 2> Ando 1
echo "Delete file: $ {Target_file}" >> $ Log_file 2> Ando 1

Rm -F $ Target_file

echo "Delete the end of work" >> $ Log_file 2> Ando 1
Else
Echo "since there is no delete file" $ {target_file} ", to skip the delete work" >> $ Log_file 2> Ando 1
Fi

Echo [ `date" +% Y /% m /% d% H:% M:% S "`] ********************************************** processing Exit ********************************************** >> $ 2 Log_file> Ando 1
Exit 0




Copy

# / Bin / Bash!

##### Define Field
Shell_name = Official_faq_intelligentsearch_preCapture.Sh

# log of the path
Log_dir = / Sb / Logs / Kwc / Scripts

If [-D $ Log_dir!]; Then
Mkdir -P $ Log_dir
Fi

# log of full path
Log_file = $ Log_dir / Official_faq_intelligentsearch_preCapture_`date 'Tasu Pasento Y Pasento M Pasento D' `.Log

# working directory
Target_dir = / Sb / Logs / IntelligentSearch

# copy the original file
pre_file = $ target_dir / intelligentSearch.log.`date' + Y- M- Pasento Pasento Pasento D '--Date' 1 Day Ago'`

# copy after the file
post_file = $ target_dir / intelligentSearch-is.log

echo [ `date" +% Y /% m /% d% H:% M:% S "` ] ************************* ********************* processing start *************************** >> $ Log_file ******************* 2> Ando 1

# if the copy after the file exists, delete
if [-F $ Post_file]; Then
Echo "after copying because there is a file "$ {post_file}", delete ">> $ Log_file 2> Ando 1
Rm -F $ Post_file
Fi
Echo" copy work start ">> $ Log_file 2> Ando 1
Echo" before copying files: $ {pre_file } ">> $ Log_file 2> Ando 1
Echo" copy after the file: $ {Post_file} ">> $ Log_file 2> Ando 1

Cp -F $ Pre_file $ Post_file

Echo" copy work finished ">> $ Log_file 2> Ando 1

Echo [` date "+% Y /% m /% d% H:% M:% S"`] ********************************************** processing end ********************************************** >> $ log_file 2> Ando 1
Exit 0




Guess you like

Origin www.cnblogs.com/taobr/p/11756796.html