Linux bash printer run time

Time:2019-12-15
#!/bin/bash

function ShowTime()
{
    endTime=`date +'%Y-%m-%d %H:%M:%S'`
    start_seconds=$(date --date="$startTime" +%s);
    end_seconds=$(date --date="$endTime" +%s);
    usedTime=$((end_seconds-start_seconds))
    #Display in red font for more than 2 seconds, yellow font for 1-2s and green font for less than 1 s
    if [[ $usedTime -ge 2 ]]
    then
        echo -e "3[31mUsed time:$usedTime s 3[0m"
    elif [[ $usedTime -ge 1 ]]
    then
        echo -e "3[33mUsed time:$usedTime s  3[0m"
    else
        echo -e "3[32mUsed time:$usedTime s 3[0m"
    fi
}


startTime=`date +'%Y-%m-%d %H:%M:%S'`
echo "Start time:$startTime"
#Execution procedure
sleep 1
ShowTime

Recommended Today

Apache sqoop

Source: dark horse big data 1.png From the standpoint of Apache, data flow can be divided into data import and export: Import: data import. RDBMS—–>Hadoop Export: data export. Hadoop—->RDBMS 1.2 sqoop installation The prerequisite for installing sqoop is that you already have a Java and Hadoop environment. Latest stable version: 1.4.6 Download the sqoop installation […]