一个linux系统中的某个文件夹无法删除,使用ls -al查看有1个.nfsxxxx的文件无法删除。

使用lsof +D /filepath/,查看到文件被一个进程一直占用。

再使用ps -aux | grep pid,查看是一个java进程一直在占用,杀掉这个进程后,文件夹正常删除。

What is this .nfsxxxxxxxxxxxxxx file and why can’t I remove it?

Under unix, if you remove a file that a currently running process still has open, the file isn’t really removed. Once the process closes the file, the OS then removes the file handle and frees up the disk blocks. This process is complicated slightly when the file that is  open and removed is on an NFS mounted filesystem. Since the process that has the file open is running on one machine (such as a workstation in your office or lab) and the files are on the file server, there has to be some way for the two machines to communicate   information about this file. The way NFS does this is with the .nfsNNNN files. If you try to remove one of these file, and the file is still open, it will just reappear with a different number. So, in order to remove the file completely you must kill the process that has it open.

If you want to know what process has this file open, you can use ‘lsof .nfs1234’. Note, however, this will only work on the machine where the processes that has the file open is running. So, if your process is running on bobac and you run the lsof on some other burrow machine, you won’t see anything.

For example:

% echo test > foo

% tail -f foo

test

^Z

Suspended

% rm foo

% ls -A

.nfsB23D

% rm .nfsB23D

% ls -A

.nfsC23D

% lsof .nfsC23D

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

tail 1257 robh 0r VREG 176,6 5 3000753 .nfsC23D

%

So, once you have located and killed the process that has the file open, the .nfs file will go away automatically. In the above example, when you kill the tail process, the .nfsC23D file will disappear.

The useful tools: ps, lsof

在本机eclipse中创建maven项目,查看linux中hadoop下的文件、在本机搭建hadoop环境

注意 第一次建立maven项目时需要在联网情况下,因为他会自动下载一些东西,不然突然终止 需要手动删除断网前建立的文件 在eclipse里新建maven项目步骤 直接新建maven项目出了错      ...

<实训|第十一天>学习一下linux中的进程,文件查找,文件压缩与IO重定向

[root@localhost~]#序言 在今后的工作中,运维工程师每天的例行事务就是使用free -m,top,uptime,df -h...每天都要检查一下服务器,看看是否出现异常.那么今天我们就 ...

Linux中/proc目录下文件详解

转载于:http://blog.chinaunix.net/uid-10449864-id-2956854.html Linux中/proc目录下文件详解(一)/proc文件系统下的多种文件提供的系统 ...

linux中增加swap分区文件的步骤方法

一.swap交换分区 Swap分区在系统的物理内存不够用的时候,把硬盘空间中的一部分空间释放出来,以供当前运行的程序使用.那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临 ...

Linux中/proc目录下文件详解(转贴)

转载:http://www.sudu.cn/info/index.php?op=article&id=302529   Linux中/proc目录下文件详解(一) 声明:可以自由转载本文, ...

漫画:Linux中/etc/resolv.conf文件和puppet工具解析

今天办公室里来了一个程序员妹子飞鸟,小鱼是给她分配的导师,初次见面~ 午饭时间 Linux目录结构 resolv.conf文件 nameserver 唯一的必选关键字.表明DNS 服务器的IP 地址, ...

Linux中常用的查找文件的命令

我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索.这些是从网上找到的资料(参考资料1),因为有时很长时间不会用到,当要用的时候经常弄混了,所以放到这里方便使用. w ...

如何设置UNIX/Linux中新创建目录或文件的默认权限

在unix或者linux中,每创建一个文件或者目录时,这个文件或者目录都具有一个默认的权限,比如目录755,文件644,那么这些默认权限是怎么控制的呢? 答案是"umask"权限掩 ...

Linux中如何产生core文件?

在程序不寻常退出时,内核会在当前工作目录下生成一个core文件(是一个内存映像,同时加上调试信息).使用gdb来查看core文件,可以指示出导致程序出错的代码所在文件和行数.   1.core文件 ...

随机推荐

C#中操作XML文件

1.添加结点:XmlNode xmldoc.Load("..\\..\\App.config"); //根元素 XmlElement root = xmldoc.DocumentE ...

commonJS — 数组操作(for Array)

for Array github: https://github.com/laixiangran/commonJS/blob/master/src/forArray.js 代码 /** * Creat ...

Xcode 7遇到 App Transport Security has blocked a cleartext HTTP 错误

今天用Xcode 7 创建新项目用到 URL 发送请求时,报下面的错: “App Transport Security has blocked a cleartext HTTP (http://) r ...

select into from和insert into select from两种表复制语句区别

select into from和insert into select from两种表复制语句都是将源表source_table的记录插入到目标表target_table,但两句又有区别. 第一句(s ...

jquery validate如何不提交表单就做验证(ajax提交数据)

if($("#FromID").valid()){ $.ajax({ type:'post', url:'/CampaignOrderRelations/save', data:{ ...

log4j 1.2配置(转载)

转载自:http://www.blogjava.net/kit-soft/archive/2009/08/28/292977.html 第一步:加入log4j-1.2.8.jar到lib下. 第二步: ...

武汉科技大学ACM :1006: 零起点学算法25——求两点之间的距离

Problem Description 输入平面坐标系中2点的坐标,输出它们之间的距离 Input 输入4个浮点数x1 y1 x2 y2,分别是点(x1,y1) (x2,y2)的坐标(多组数据) Ou ...

【转】android电池(四):电池 电量计(MAX17040)驱动分析篇

关键词:android 电池  电量计  MAX17040 任务初始化宏 power_supply 平台信息:内核:linux2.6/linux3.0系统:android/android4.0 平台: ...

LDA主题模型学习笔记3.5:变分參数推导

如今来推导一下得到变分參数更新式的过程.这一部分是在论文的附录中,为避免陷入过多细节而影响总体理解.能够在刚開始学习LDA的时候先不关注求解细节.首先要把L写成关于γ,ϕ\gamma,\phi函数.依 ...

Logo

更多推荐