proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« 山西的宽带运营商太过分了 私自窜改dns解析 | Main | [php] realip judge 前面补0的ip格式剔除 »

December 14, 2007

rm -rf * 系统管理员要排查的定时炸弹

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
http://windtear.net/archives/2007/12/14/001298.html

很简单的一件事
很严重的后果
具体就不多说了

系统管理员需要注意的就是查一下
crontab 里面有没有调用 rm -rf * 的地方

/etc/crontab 这里的 PWD 环境变量是 /
root 帐号 crontab -e 添加的定时任务 PWD 环境变量是 /root

这里面如果写的容错性判断不完善的话
导致 rm -rf * 在 / 目录执行
后果就是整个数据没了...

所谓容错性判断 比较好的是用 find
find /path ... | xargs rm -rf

千万不要用
cd /path
rm -fr *

万一谁不小心把 /path 删了
就会出现 rm -rf * 在 / 执行的恶劣情况
所以 rm -rf * 是系统管理员要排查的定时炸弹/或者不定时炸弹

本blog WWW

Posted by windtear at December 14, 2007 4:34 PM

Trackback Pings

TrackBack URL for this entry:
http://cgi.windtear.net/cgi-bin/wt-tb.cgi/1298

Comments

find /foo bar -exec rm {} \;
这样的方式有何不同呢?

ps:你的mt没有打开typekey的支持

Posted by: goergexsh at December 29, 2007 2:48 AM

typekey 打开了

xargs 更好 呵呵
如果文件太多的话 exec 方式就不行了

Posted by: windtear [TypeKey Profile Page] at December 30, 2007 5:26 PM

晕,太多是多少呢?我一直用这个方式的说,删十万级别是可以的
-exec也是逐个解释过去的吧?

Posted by: George [TypeKey Profile Page] at January 3, 2008 1:48 AM

-exec 有两种情况
一种是一次传过去执行 这种文件量很大不行
一种是逐个传过去执行 这种方式每次会起一个进程 不够完美

Posted by: windtear at January 3, 2008 2:12 PM

受教了,谢谢windtear
manpage 里讲
-exec command {} +
"The command line is built in much the same way that xargs builds its
command lines. Only one instance of ’{}’ is allowed within the command. The command is executed in the starting directory."

Posted by: George [TypeKey Profile Page] at January 4, 2008 12:42 AM

Post a comment

Remember Me?



我爱网络
2007-12-31 23:51 2007年度 ipcn.org/ipchina.org 总结报告
2007-12-31 00:31 vmware gsx server service
2007-12-31 00:15 squid 对 404 302 缓存的相关问题
2007-12-30 14:24 升级到 MovableType 3.3x 并修改 entry_basename 兼容性
2007-12-30 13:52 [php] realip judge 前面补0的ip格式剔除
2007-12-14 16:34 rm -rf * 系统管理员要排查的定时炸弹
2007-12-13 19:03 山西的宽带运营商太过分了 私自窜改dns解析
2007-12-13 16:35 F5 MIB 再学习 唯一性标记用地址的小bug
2007-12-11 22:15 perl 用Spreadsheet::WriteExcel写了个处理/读写excel的小程序
2007-12-11 13:39 perl 变量转义的问题

本站使用中的任何问题,请与 windtear SPAM windtear SPAM net 联系
Copyright© 1999-2008 Windtear. All rights reserved.
京ICP备05050670号