自动清理3个月前的文件

上一篇 / 下一篇  2015-01-09 09:46:50 / 个人分类:Linux shell

#grab today's date in YYYYMMDD format
today=$(date +%Y%m%d)
#grab date as of 3 months ago in YYYYMMDD format
three_months_ago=$(date +%Y%m%d --date='3 months ago')

#now convert dates to "seconds since epoch" format, and then divide the difference  by 60*60*24 to convert from seconds to days
printf '%d\n' $(( ($(date --date=$today +%s) - \
  $(date --date=$three_months_ago +%s))/(60*60*24) ))
91

TAG: shell Shell

ElenaYu的个人空间 引用 删除 ElenaYu   /   2015-01-13 10:34:57
原帖由aaaaaasda于2015-01-12 16:22:18发表
怎么用

登陆服务器,代码写进去就可以了~
aaaaaasda的个人空间 引用 删除 aaaaaasda   /   2015-01-12 16:22:18
怎么用
 

评分:0

我来说两句

日历

« 2024-03-05  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

我的存档

数据统计

  • 访问量: 66785
  • 日志数: 20
  • 建立时间: 2015-01-06
  • 更新时间: 2015-01-21

RSS订阅

Open Toolbar