LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Issues with the rm command (https://www.linuxquestions.org/questions/linux-newbie-8/issues-with-the-rm-command-753201/)

ripvtech 09-06-2009 10:38 PM

Issues with the rm command
 
Hello,
I'm in the process of automating the deployment of my webapps, and I have noticed an issue with removing one of my directories.

I run rm -rfv /path/to/directory

It outputs the following:

removed directory: `mockstore//category'
removed `my_project//environment.pyc'
removed `my_project//environment.py~'
removed `my_project//manage.py'
removed `my_project//my_project.kpf'
removed `my_project//search/.DS_Store'
removed `my_project//search/._.DS_Store'
removed `my_project//search/models.py'
removed `my_project//search/models.pyc'
removed `my_project//search/services.py'
removed `my_project//search/services.pyc'
removed `my_project//search/urls.py'
removed `my_project//search/urls.pyc'
removed `my_project//search/views.py'
removed `my_project//search/views.pyc'
removed `my_project//search/__init__.py'
removed `my_project//search/__init__.pyc'

It seems any folder I try to delete the rm command freezes after deleting an __anyfile__.pyc file

Any ideas?

Thanks

gregorian 09-06-2009 10:43 PM

I'm unable to replicate your problem. I created a folder called tmp and added _anyfile__.pyc to it. rm -rvf tmp worked without any issues. Could you isolate your problem to smaller context?

piratas 09-06-2009 10:50 PM

It works fine for me.
Have you checked the privileges?

ripvtech 09-06-2009 11:38 PM

Ok so this is extremely odd. If I do the following
cp -r /my_project /my_project_bak
rm -rvf /my_project_bak

The copied folder deletes without an issue.

If I try:

mv /my_project /my_project_moved
rm -rvf /my_project_moved

I still can't delete the moved folder.

For a little more context.

The lockup occurs after it deletes all the files within the directory, it seems it can't remove the directory itself.
If I then stop the command by pressing ctrl+c and run it again, the folder deletes just fine

ripvtech 09-06-2009 11:39 PM

Yes I have checked the permissions.

windtalker10 09-07-2009 12:13 AM

It sounds like you may have created a link with the directory somehow.
Try adding d to the rm command.

ripvtech 09-07-2009 12:44 AM

Adding d did not yield different results.


rm -rvfd /my_project

still fails on removing the directory. There are no symlinks inside this folder.

Valery Reznic 09-07-2009 08:37 AM

Quote:

Originally Posted by ripvtech (Post 3672573)
Adding d did not yield different results.


rm -rvfd /my_project

still fails on removing the directory. There are no symlinks inside this folder.

Try run it under strace
Code:

strace rm -rvfd /my_project
It can shred a light to the problem

ripvtech 09-07-2009 08:50 PM

I ran strace -f -o strace.out rm -rf /django_projects

here is the output ( sorry for the dump I didn't see an attach file option):

3017 execve("/bin/rm", ["rm", "-rf", "/django_projects/"], [/* 36 vars */]) = 0
3017 brk(0) = 0x8b51000
3017 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
3017 open("/etc/ld.so.cache", O_RDONLY) = 3
3017 fstat64(3, {st_mode=S_IFREG|0644, st_size=41168, ...}) = 0
3017 mmap2(NULL, 41168, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7ef8000
3017 close(3) = 0
3017 open("/lib/libc.so.6", O_RDONLY) = 3
3017 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\320\216\0004\0\0\0"..., 512) = 512
3017 fstat64(3, {st_mode=S_IFREG|0755, st_size=1673804, ...}) = 0
3017 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ef7000
3017 mmap2(0x8d7000, 1390032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x8d7000
3017 mmap2(0xa25000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14e) = 0xa25000
3017 mmap2(0xa28000, 9680, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xa28000
3017 close(3) = 0
3017 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ef6000
3017 set_thread_area({entry_number:-1 -> 6, base_addr:0xb7ef66c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
3017 mprotect(0xa25000, 8192, PROT_READ) = 0
3017 mprotect(0x8d3000, 4096, PROT_READ) = 0
3017 munmap(0xb7ef8000, 41168) = 0
3017 brk(0) = 0x8b51000
3017 brk(0x8b72000) = 0x8b72000
3017 open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
3017 fstat64(3, {st_mode=S_IFREG|0644, st_size=65179696, ...}) = 0
3017 mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7cf6000
3017 close(3) = 0
3017 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
3017 lstat64("/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
3017 fstatat64(AT_FDCWD, "/django_projects/", {st_mode=S_IFDIR|0777, st_size=0, ...}, AT_SYMLINK_NOFOLLOW) = 0
3017 openat(AT_FDCWD, "/django_projects/", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW) = 3
3017 fstat64(3, {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
3017 fstat64(3, {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0
3017 fcntl64(3, F_GETFL) = 0x28800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_NOFOLLOW)
3017 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
3017 getdents64(3, /* 2 entries */, 4096) = 48
3017 getdents64(3, /* 0 entries */, 4096) = 0
3017 fcntl64(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
3017 close(3) = 0
3017 unlinkat(AT_FDCWD, "/django_projects/", AT_REMOVEDIR) = -1 EBUSY (Device or resource busy)
3017 open("/usr/share/locale/locale.alias", O_RDONLY) = 3
3017 fstat64(3, {st_mode=S_IFREG|0644, st_size=2528, ...}) = 0
3017 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f02000
3017 read(3, "# Locale name alias data base.\n#"..., 4096) = 2528
3017 read(3, "", 4096) = 0
3017 close(3) = 0
3017 munmap(0xb7f02000, 4096) = 0
3017 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 write(2, "rm: ", 4) = 4
3017 write(2, "cannot remove directory `/django"..., 43) = 43
3017 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
3017 write(2, ": Device or resource busy", 25) = 25
3017 write(2, "\n", 1) = 1
3017 close(1) = 0
3017 close(2) = 0
3017 exit_group(1) = ?

ripvtech 09-07-2009 09:41 PM

So I figured it out. I'm a complete idiot! The parent folder was a mounted folder and hence causing all kinds of issues.

I have unmounted the folder and all my issues have gone away!

Thank you for all the help!


All times are GMT -5. The time now is 07:52 AM.