码迷,mamicode.com
首页 > 系统相关 > 详细

linux week3

时间:2018-06-15 16:01:44      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:mkdir   UI   color   处理   lin   AC   div   1.5   ESS   

 

2.如何快速的回到 上?一次所在的位置 

cd An argument of - is equivalent to $OLDPWD. 
cd -  #cd $OLDPWD cd - #快速的回到 上?一次所在的位置 
cd .  #当前目录 复制/移动 
cd .. #进入当前?目录的上级?目录 
cd ~  #进入当前?目录的家?目录 回?老老家 
cd    #进?当前?目录的家?目录 等同于cd ~
 
 
 

第4题 

已知apache/nginx服务的访问?日志按天记录在服务?本地?目录/app/logs 下,由于磁盘空间紧张,现在要求只能保留留最近7天访问?日志!请问如何解决? 请给出解决 办法或配置或处理理命令。(提示:可以从apache服务配置上着手,也可以从?生成出来的日志上着手。)
 
模拟环境
mkdir -p /app/logs 
cd /app/logs 
for time in {01..15};do date -s "201806$time"; touch access_www_$(date +%F).log ;done
date -s "20170520" 
1.
[root@web02 logs]# find /app/logs -type f -mtime +7 |xargs ls -lrt
-rw-r--r-- 1 root root 0 6月 1 00:00 /app/logs/access_www_2018-06-01.log
-rw-r--r-- 1 root root 0 6月 2 00:00 /app/logs/access_www_2018-06-02.log
-rw-r--r-- 1 root root 0 6月 3 00:00 /app/logs/access_www_2018-06-03.log
-rw-r--r-- 1 root root 0 6月 4 00:00 /app/logs/access_www_2018-06-04.log
-rw-r--r-- 1 root root 0 6月 5 00:00 /app/logs/access_www_2018-06-05.log
-rw-r--r-- 1 root root 0 6月 6 00:00 /app/logs/access_www_2018-06-06.log
-rw-r--r-- 1 root root 0 6月 7 00:00 /app/logs/access_www_2018-06-07.log
找出/app/logs下?面以.log结尾的并且修改时间是7天之前的?文件并删除(ls -l) 
 
[root@web02 logs]# find /app/logs -type f -name "*.log" -mtime +7 |xargs ls -lrt
 
2.
[root@web02 logs]# ls -lrt $(find /app/logs -type f -name "*.log" -mtime +7)
3.
[root@web02 logs]# find /app/logs -type f -name "*.log" -mtime +7 -exec ls -l {} \;
4.
通过系统软件对?日志进?行行切割
 

 

linux week3

标签:mkdir   UI   color   处理   lin   AC   div   1.5   ESS   

原文地址:https://www.cnblogs.com/wenyule/p/8c0bf725342edef852d2006bde03ce62.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!