shell script to get the current time, 1 minute ago period, one hour before the time and the day before time

# Get the current time

time=`date +"%Y-%m-%d %H:%M:%S"`

# Get a minute ago

time=`date -d "1 minute ago" +"%Y-%m-%d %H:%M:%S"`

Get one hour before #

time=`date -d "1 hour ago" +"%Y-%m-%d %H:%M:%S"`

# Get the day before the time

time=`date -d "1 day ago" +"%Y-%m-%d %H:%M:%S"`

Guess you like

Origin blog.csdn.net/weixin_42591674/article/details/91503895
Recommended