美文网首页
擦除文件

擦除文件

作者: 张霸天 | 来源:发表于2017-06-01 18:52 被阅读0次
 cat /dev/null > messages

You typically cat /dev/null > [something] when you want to wipe file contents while ensuring there is absolutely zero risk of interruption to the actual file state. The contents of the file will clearly be wiped by the cat /dev/null yet the file itself—as it exists and is known to the file system it resides on—will still be there with the same inode number, ownership and permissions.

In the case of a log file, it could be that the log file itself is marked “in use” by another process. So doing—for example—an rm /var/log/messages && touch /var/log/messages would be disruptive to other processes and might cause running processes to choke. Meaning a process that somehow is locked to a specific inode number connected to the file /var/log/messages could suddenly panic and say, “Hey! What happened to /var/log/messages!” even if the file is still there. Not to mention potential issues with ownership and permissions being incorrectly recreated.

Because of this uncertainty in usage/state of a file the use of cat /dev/null > [something] is preferred by system admins who want to clear out a log but do not want to potentially interfere with the operation of already existing processes.

相关文章

  • 擦除文件

    You typically cat /dev/null > [something] when you want t...

  • erase — 擦除磁盘文件

    描述 erase命令用于擦除存储在磁盘上的文件,rm是erase作用一致。注意:擦除是永久的,文件不会被移动到回收...

  • 泛型

    类型擦除 java的泛型比较重要的一点是类型擦除。避免生成多个class文件** 例子 ** ** javap看字...

  • 泛型

    泛型用于编译时期,确保类型的安全 在运行时,会将泛型去掉,class文件是不带泛型的,这个称为泛型的擦除,擦除是为...

  • u-boot之Nand Flash操作

    擦除Nand Flash (1)整片擦除 nand erase.chip (2)分区擦除 nand erase.p...

  • 文件彻底粉碎、擦除和覆盖 – cipher 命令使用方法

    文件彻底粉碎、擦除和覆盖 – cipher 命令使用方法 有些时候出于对隐私的保护,我们会对要删除的文件进行彻底粉...

  • 强力保护系统和上网隐私安全

    保护您的系统和互联网上的隐私 隐藏您的图片,视频,文档 用密码锁定文件和文件夹 为您创建个人空间 安全擦除敏感文件...

  • 图片擦除

    图片擦除思路.弄两个不同的图片.上面一张, 下面一张.添加手势,手指在上面移动,擦除图片.擦除前要先确定好擦除区域...

  • [译]Swift 中的类型擦除

    你可能听过这个术语 :类型擦除。甚至你也用过标准库中的类型擦除(AnySequence)。但是具体什么是类型擦除,...

  • Basic Sky Replacement——AK01

    选中新的天空,效果——过渡——线性擦除 {线性擦除效果讲解:过渡完成——百分比例;擦出角度——控制擦除方向;羽化—...

网友评论

      本文标题:擦除文件

      本文链接:https://www.haomeiwen.com/subject/tzwefxtx.html