1、写一个脚本查找最后创建时间是三天前,后缀是*.log的文件并删除

find .-ctime +3 -name '*.log' | rm -rf

2、统计ip访问情况,要求分析nginx访问日志,找出访问页面数量在前十位的ip

cataccess.log | awk '{print $1}' | uniq -c | sort -rn | head -10

3、使用tcpdump监听主机为192.168.1.1,tcp端口为80的数据,同时将输出结果保存输出到tcpdump.log。

tcpdump 'host 192.168.1.1 and port 80' > tcpdump.log

4、利用Python打印前一天的本地时间,格式为'2016-03-29 13:58:34'

time.strftime('%y-%m-%d%H:%M%:%S' time.locatime(time.time() -86400))

5、用Python将‘123456’反转为‘654321’

‘123456’[::-1]

6、利用Python执行shell命令并取得返回结果

>>> import subprocess>>>

a=subprocess.popen('ls',shell=True,stdout=subprocoss.PIPE, stderr=subprocess.PIPE)>>>stdout,sterr = a.communicate()>>>print stdout

7、请用Python继承process,并写一个并行执行的类,并写出使用过程。

import multiprocessingimport timeclass ClockProcess(multiprocessing.Process):    def __init__(self, interval):        multiprocessing.Process.__init__(self)        self.interval = interval    def run(self):        n = 5        while n > 0:            print("the time is {0}".format(time.ctime()))            time.sleep(self.interval)            n -= 1

8、如何将本地80 端口的请求转发到8080 端口,当前主机IP 为192.168.2.1

Iptables –t nat -A PREROUTING -d 192.168.2.1 -p tcp  –dport 80 -j REDIRECT --to 8080

9、在11 月份内,每天的早上6 点到12 点中,每隔2 小时执行一次/usr/bin/httpd.sh 怎么实现

0 6-12/2 * 11 * /usr/bin/httpd.sh

10、编写个shell 脚本将/usr/local/test 目录下大于100K 的文件转移到/tmp目录下

find /usr/local/test -type f -size +100k -exec mv {} /tmp/

#!/bin/bashfilelist=$(ls  /usr/local/test -l | grep "^-" | awk '{print $9}') filepath="/usr/local/test"for file in $filelistdo    filesize=$(du -s $filepath$file |awk '{print $1}')    if [ $filesize -gt 100]    then    mv $filepath$file /tmp/fidone

11、如何查看占用端口8080 的进程

netstat -anpt | grep 8080

lsof -i :8080