add deleting logs

This commit is contained in:
Сергей Гудаев 2023-06-17 01:15:37 +08:00
parent 7599a9435e
commit 0705ae79c6

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# about script
version="17/06/23"
PRMT="[$(whoami)@$(hostname -s) ]" PRMT="[$(whoami)@$(hostname -s) ]"
@ -24,7 +26,7 @@ function askYesNo {
} }
_logs3days(){ _logs3days(){
files3d=($(find . -maxdepth 1 -mtime -3 -iname "*logs*" -o -mtime -3 -iname "*vm_lic*" -o -mtime -3 -iname "*vm_node*" -o -mtime -3 -iname "*short-logs*")); files3d=($(find . -maxdepth 1 ! -iname "*log*.sh" -mtime -3 -iname "*logs*" -o -mtime -3 -iname "*vm_lic*" -o -mtime -3 -iname "*vm_node*" -o -mtime -3 -iname "*short-logs*"));
if [[ ${#files3d[@]} >0 ]];then if [[ ${#files3d[@]} >0 ]];then
echo -e "\n*********************** platform's logs for last 3 days *************************\n"; echo -e "\n*********************** platform's logs for last 3 days *************************\n";
for item3d in ${files3d[*]} for item3d in ${files3d[*]}
@ -39,7 +41,7 @@ _logs3days(){
} }
_remove_logs (){ _remove_logs (){
files=($(find . -maxdepth 1 -mtime +3 -iname "*logs*" -o -mtime +3 -iname "*vm_lic*" -o -mtime +3 -iname "*vm_node*" -o -mtime +3 -iname "*short-logs*")); files=($(find . -maxdepth 1 -mtime +3 -iname "*logs*" -o -mtime +3 -iname "*vm_lic*" -o -mtime +3 -iname "*vm_node*" -o -mtime +3 -iname "*short-logs*" ! -iname "get*log*.sh"));
if [[ ${#files[@]} >0 ]];then if [[ ${#files[@]} >0 ]];then
echo "founded platform logs older than last 3 days"; echo "founded platform logs older than last 3 days";
@ -207,8 +209,6 @@ node_collect() {
} }
_help(){ _help(){
# about script
version="15/04/23"
echo -e "*********************************************************************************"; echo -e "*********************************************************************************";
echo -e "*\t\t\tISPsystem technical support\t\t\t\t*"; echo -e "*\t\t\tISPsystem technical support\t\t\t\t*";
echo -e "*\t\t\tLog's script ver.: $version\t\t\t\t*"; echo -e "*\t\t\tLog's script ver.: $version\t\t\t\t*";
@ -221,6 +221,8 @@ echo -e "\t-lic or 3\t\t\t\t logs about license";
echo -e "\t-node or 4 <IP-address> <SSH-port>\t node's logs\n"; echo -e "\t-node or 4 <IP-address> <SSH-port>\t node's logs\n";
_logs3days; _logs3days;
_remove_logs;
echo -e "\t\t\t\t *** MENU ***\t\t\t\t\n"; echo -e "\t\t\t\t *** MENU ***\t\t\t\t\n";
PS3='Please enter your choice(enter number): ' PS3='Please enter your choice(enter number): '
# interactive menu # interactive menu