• 自动删除当前目录及其子目录下的所有PetaLinux工程的build目录下的临时文件,释放2TB硬盘空间


    服务器报告硬盘没有空间。

    执行脚本peta-del-build-temp.sh,自动删除当前目录及其子目录下的所有PetaLinux工程的build目录下的临时文件,最后从历年遗留的100多个工程中释放了2TB硬盘空间。

    peta-del-images-unused.sh 内容如下:

    #!/bin/bash
    # hankf@amd.com
    
    echo -e "\nBegin to run script: $0"
    
    # $1: target-petalinux-image-directory
    if [ "$1" = "" ]; then
        echo "Invalid target directory."
        echo "Usage: $0 target-petalinux-image-directory."
    fi
    
    echo "Check petalinux image directory: $1"
    ls -l -h $1
    
    if [ ! -f  $1/u-boot.elf ]; then 
        echo "Not PetaLinux project image directory, No u-boot.elf."
        echo "Exit."
        exit 1
    fi 
    
    if [ ! -f  $1/system.dtb ]; then 
        echo "Not PetaLinux project image directory, No system.dtb."
        echo "Exit."
        exit 1
    fi 
    
    # array definition, work for /bin/bash, does not work for /bin/sh
    array_image_type_remove=( 
    .cpio
    .ext2
    .ext3
    .ext4
    .jffs2
    .tar
    .bin
    .bz2
    .gz
    .u-boot
    Image
    vmlinux
    )
    
    # Get array elements number
    image_type_remove_length=${#array_image_type_remove[@]}
    
    # C-language style loop
    for (( i=0; i<$image_type_remove_length; i++))
    {
        image_remove=$1/*${array_image_type_remove[i]}
        echo "Remove No.$i image: $image_remove";
        rm -rf $image_remove    
    }
    
    echo "Files in petalinux image directory: $1 after deleting."
    ls -l -h $1
    
    echo -e "Complete script: $0"
    

    peta-del-build-temp-inner.sh 内容如下:

    hankf@amd.com

    #!/bin/bash
    # hankf@amd.com
    
    echo -e "\nBegin to run script: $0"
    
    if [ "$1" = "" ]; then
        echo "Invalid target directory."
        echo "Usage: $0 target-petalinux-build-directory."
    fi
    
    echo "Check petalinux build directory: $1"
    ls -l $1
    
    # array definition, work for /bin/bash, does not work for /bin/sh
    dir_array_check=( 
    cache 
    conf
    downloads
    misc
    sstate-cache
    tmp
    ../build/downloads
    ../build/sstate-cache
    ../build/tmp
    ../components/plnx_workspace/device-tree/
    ../project-spec/
    ../project-spec/configs/
    ../project-spec/hw-description/
    ../project-spec/meta-user/conf
    ../project-spec/meta-user/recipes-bsp/
    )
    
    # Get array elements number
    dir_array_check_length=${#dir_array_check[@]}
    
    # C-language style loop
    for (( i=0; i<$dir_array_check_length; i++))
    {
        CHECK_DIR=$1/${dir_array_check[i]}
        echo "Check No.$i directory: $CHECK_DIR";
        if [ ! -d  $CHECK_DIR ]; then 
            echo "Not PetaLinux project build directory. No directory: $CHECK_DIR. "
            echo "Exit."
            exit 1
        fi 
    }
    
    echo "It is PetaLinux project build directory."
    
    echo "Delete PetaLinux temp files."
    rm -rf $1/../build/cache/*
    rm -rf $1/../build/conf/*
    rm -rf $1/../build/downloads/*
    rm -rf $1/../build/misc/*
    rm -rf $1/../build/sstate-cache/*
    rm -rf $1/../build/tmp/*
    
    # Delete unused image too.
    peta-del-images-unused.sh  $1/../images/linux/
    peta-del-images-unused.sh  $1/../pre-built/linux/images/
    
    echo -e "Complete script: $0"
    

    peta-del-build-temp.sh 内容如下:

    #!/bin/bash
    # hankf@amd.com
    
    
    echo -e "\nBegin to run script: $0"
    
    find -name "build" | xargs -n 1 peta-del-build-temp-inner.sh 
    
    echo -e "Complete script: $0"
    
  • 相关阅读:
    滚动条CSS样式控制浏览器滚动条颜色的代码
    Javascript中的 window.status 属性的使用方法
    javaScript中的事件驱动
    Js调用游览器的外部方法(设首页,收藏夹等游览器操作)
    js中document.documentElement 和document.body 以及其属性
    ActiveXObject 所支持的参数对象部分列表(自带)
    js中prototype用法
    Javascript中的 window.event 所有对象
    Javascript中的冒号
    HTML精确定位:scrollLeft,scrollWidth,clientWidth,offsetWidth等之完全详解
  • 原文地址:https://www.cnblogs.com/hankfu/p/16670294.html
Copyright © 2020-2023  润新知