Category Archives: Shell Script

Delete snapshots older than 7 days

To avoid running out of disk space in our test environment, we developed a plan to regularly execute shell scripts to clean up unnecessary snapshots.

Posted in HBase, Shell Script | Comments Off on Delete snapshots older than 7 days

[Shelll Script] check tomcat status

!/bin/bash tomcat7=$(ps -ef | grep tomcat | wc -l) echo ${#tomcat7} if [ ${#tomcat7} -gt 0 ]; then printf “tomcat is running\n” else printf “tomcat is not running\n” fi

Posted in Linux, Shell Script, Tomcat | Leave a comment

Redirect stdout to logFile in shell script

source: stackoverflow: redirect COPY of stdout to log file from within bash script itself

Posted in Shell Script | Leave a comment

find unused files and delete them

find /var/log/radius/radacct -type f -name “reply*” -mtime +60 -exec rm -rf {} \; -mtime N — more than N days without being edited -exec CMD {} \; — comands, {} means the files which be found.

Posted in Linux, Shell Script | Leave a comment

Parse JSON string via command line

Ref.:How to parse JSON string via command line on Linux Ubuntu: apt-get install jq Mac: brew install jq

Posted in Shell Script | Leave a comment

Redir 每日記錄回報

Posted in Linux, Shell Script | Leave a comment

Shell Script Dialog

Dialog 預設設定通常在個人Home目錄下的檔案”.dialogrc” 可使用指令 “dialog –create-rc ~/.dialogrc” 產生 因為預設底色是青色,結束後會有色塊殘留,所以建議將screen_color調整為黑色 也可在 dialog 指令執行前先指定使用哪一個設定檔案進行dialog “export DIALOGRC=${path}/dialog.installer” 記得離開前把DIALOGRC清空就好 下面是將常用的dialogrc寫成function

Posted in Shell Script | Leave a comment

Shell Script 計算字元

cowman@ubuntu:~$ string=”0123 56 89″; echo “length: ${#strstring ing}” length: 10

Posted in Linux, Shell Script | Leave a comment