#!/bin/sh
dir=/home/apache/media/record
cd $dir
find *.* -mtime +1 -exec rm -rf {} \;
从find命令运行的这一天算起,删除1天前/home/apache/media/record下所有文件
#!/bin/sh
dir=/home/apache/media/record
cd $dir
find *.* -mtime -1 -exec rm -rf {} \;
从find命令运行的这一天算起,删除1天内/home/apache/media/record下所有文件
find命令学习
[root@hntx-py-nlx-ems ~]# cd /home/root.adminssh/
[root@hntx-py-nlx-ems root.adminssh]# ls
localraidtools raidmgr_loc_forLSI518.tgz
[root@hntx-py-nlx-ems root.adminssh]# find /home/root.adminssh/ -print(列出/home/root.adminssh下的所有文件夹及其文件)
/home/root.adminssh/
/home/root.adminssh/.bash_logout
/home/root.adminssh/.bash_profile
/home/root.adminssh/.bashrc
/home/root.adminssh/.bash_history
/home/root.adminssh/raidmgr_loc_forLSI518.tgz
/home/root.adminssh/localraidtools
/home/root.adminssh/localraidtools/megamgr
/home/root.adminssh/localraidtools/dudrh72-118c.gz-image
/home/root.adminssh/localraidtools/dudrh72-118c.gz-image/dud73.img
/home/root.adminssh/localraidtools/dudrh72-118c.gz-image/rh73dud-118c.gz
/home/root.adminssh/localraidtools/dudrh72-118c.gz-image/rwfloppy.exe
/home/root.adminssh/localraidtools/megamgr.bin
/home/root.adminssh/.kde
/home/root.adminssh/.kde/Autostart
/home/root.adminssh/.kde/Autostart/.directory
/home/root.adminssh/.gtkrc
[root@hntx-py-nlx-ems root.adminssh]# find /home/root.adminssh/ -type f -size 0 -exec ls -al {} \;(显示出/home/root.adminssh/下文件长度为0的普通文件)
[root@hntx-py-nlx-ems root.adminssh]# find /home/ -type f -size 0 -exec ls -al {} \;(显示出/home/下文件长度为0的普通文件)
-rw-r--r-- 1 root root 0 2007-07-04 /home/apache/backup_log/4.8.2/resolv.conf
-rw-r--r-- 1 root root 0 2008-05-14 /home/vnmsys/verupdateclient/updateclient.log
-rw-r--r-- 1 root root 0 3月 24 10:32 /home/vnmsys/upgradeclient/bin/debug.2009-03-24
-r-xr-xr-x 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/ADU_STOP_FRONT_PROCESS_TRIGGER
-r-xr-xr-x 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/ADU
-r-xr-xr-x 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/ADU_STOP_DAEMON_TRIGGER
-r-xr-xr-x 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/ADU_MUTEX
-r--r--r-- 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/.svn/text-base/ADU_STOP_DAEMON_TRIGGER.svn-base
-r--r--r-- 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/.svn/text-base/ADU_MUTEX.svn-base
-r--r--r-- 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/.svn/text-base/ADU_DAEMON_PROCESS_RUNNING.svn-base
-r--r--r-- 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/.svn/text-base/ADU_STOP_FRONT_PROCESS_TRIGGER.svn-base
-r--r--r-- 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/.svn/text-base/ADU.svn-base
-r--r--r-- 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/.svn/text-base/ADU_TERM_PROCESS_RUNNING.svn-base
-r-xr-xr-x 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/ADU_DAEMON_PROCESS_RUNNING
-r-xr-xr-x 1 root root 0 2008-04-07 /home/NMA_2.1_Update/Server/judge/hpadu/locks/ADU_TERM_PROCESS_RUNNING
[root@hntx-py-nlx-ems root.adminssh]#
[root@hntx-py-nlx-ems root.adminssh]# ls
localraidtools raidmgr_loc_forLSI518.tgz
[root@hntx-py-nlx-ems root.adminssh]# find /home/root.adminssh/ -type f -mtime +5 -exec ls -al {} \;(显示出/home/root.adminssh/目录下更改时间为5天前的普通文件)
-rw-r--r-- 1 root.adminssh root.adminssh 24 2007-06-14 /home/root.adminssh/.bash_logout
-rw-r--r-- 1 root.adminssh root.adminssh 191 2007-06-14 /home/root.adminssh/.bash_profile
-rw-r--r-- 1 root.adminssh root.adminssh 124 2007-06-14 /home/root.adminssh/.bashrc
-rwxr-xr-x 1 root.adminssh root.adminssh 1458 5月 31 13:16 /home/root.adminssh/.bash_history
-rw-r--r-- 1 root.adminssh root.adminssh 394255 3月 25 14:38 /home/root.adminssh/raidmgr_loc_forLSI518.tgz
-rwxrwxrwx 1 1000 513 690 2002-08-12 /home/root.adminssh/localraidtools/megamgr
-rw-r--r-- 1 1000 513 1474560 2002-05-22 /home/root.adminssh/localraidtools/dudrh72-118c.gz-image/dud73.img
-rw-r--r-- 1 1000 513 70360 2002-07-17 /home/root.adminssh/localraidtools/dudrh72-118c.gz-image/rh73dud-118c.gz
-rwxr-xr-x 1 1000 513 32768 2000-01-06 /home/root.adminssh/localraidtools/dudrh72-118c.gz-image/rwfloppy.exe
-rwxrwxrwx 1 1000 513 555092 2002-08-12 /home/root.adminssh/localraidtools/megamgr.bin
-rw-r--r-- 1 root.adminssh root.adminssh 381 2007-06-14 /home/root.adminssh/.kde/Autostart/.directory
-rw-r--r-- 1 root.adminssh root.adminssh 120 2007-06-14 /home/root.adminssh/.gtkrc
[root@hntx-py-nlx-ems root.adminssh]#
command >out.file 2>&1 &
在上面的例子中,所有的标准输出和错误输出都将被重定向到一个out.file的文件中.当你成功地提交进程后,系统会显示一个进程号,可以用它来监控该进程,或杀死它.
如果使用nohup命令提交作业,那么缺省情况下该作业的所有输出都被重定向到一个名为nohup.out的文件中,除非指定了输出文件:
nohup command >myout.file 2>&1
上面的例子,输出被重定向到myout.file文件中
阅读(663) | 评论(0) | 转发(0) |