Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Deleting a million of files .. Post 302897598 by rbatte1 on Tuesday 15th of April 2014 04:55:42 AM
Old 04-15-2014
If actual elapse time is critical because of ongoing processing, could I suggest:-
Code:
mv /path /path-to-del
mkdir -m 777 /path
chown user:group /path

Doing this will be a near instantaneous operation and then with the directory renamed and a new empty one created, your processing can continue whilst you dispose of what is now called /path-to-del at your leisure.

The -m 777 on the mkdir sets the permissions for the directory. The user:group on the chown sets both the owner and group in one operation, rather than having to do a chown and a chgrp


I might be way off course, but I was confused as to why the timing matters so much. If you still want a choice for your original question, I would go with rm -f /path


Another alternate might be available if this is a filesystem you can unmount for a few moments:-
Code:
umount /path
newfs your-options /dev/logical-volume
mount /path

You don't give us an OS or any clue about what devices the disks are on, so I've tried to be generic here. You make have to use mkfs, crfs, fscreate or other things depending what you are running. Of course, this may not be an option.



I hope that these suggestions might help.

Robin
Liverpool/Blackburn
UK
This User Gave Thanks to rbatte1 For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help comparing two files and deleting some things in those files!

So I have two files: File1 pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2 pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2 ref4948 1.1 treehouse.txt 1.6 ref8573 1.5 ref3284 1.4 ref5838... (24 Replies)
Discussion started by: linuxkid
24 Replies

2. Solaris

Need to know command to delete more than 3 million files from /var/spool/clientmqueue

Hi I need to delete more than 3 million files from /var/spool/clientmqueue. When I give the following command to delete the files, I get the error # pwd /var/spool/clientmqueue # rm -f * /usr/bin/rm: arg list too long Please tell me how can I delete the files (5 Replies)
Discussion started by: sb200
5 Replies

3. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

4. Shell Programming and Scripting

Deleting files

Hi all, I have developed a shell script to copy the files from source to destination and simultaneously to delete the copied files in source. I can copy the files but the files cannot be deleted in source side. (3 Replies)
Discussion started by: Venkatesan
3 Replies

5. Shell Programming and Scripting

Matching 10 Million file records with 10 Million in other file

Dear All, I have two files both containing 10 Million records each separated by comma(csv fmt). One file is input.txt other is status.txt. Input.txt-> contains fields with one unique id field (primary key we can say) Status.txt -> contains two fields only:1. unique id and 2. status ... (8 Replies)
Discussion started by: vguleria
8 Replies

6. Shell Programming and Scripting

Fast processing(mv command) of 1 million+ files using find, mv and xargs

Hi, I'd like to ask if anybody can help improve my code to move 1 million+ files from a directory to another: find /source/dir -name file* -type f | xargs -I '{}' mv {} /destination/dir I learned this line of code from this forum as well and it works fine. However, file movement is kinda... (6 Replies)
Discussion started by: agentgrecko
6 Replies

7. UNIX for Dummies Questions & Answers

Pls. help with script to remove million files

Hi, one of the server, log directory was never cleaned up. We have so many files. I want to remove all the files that starts with dfr* but I get error message when I use the *. rm qfr* bash: /usr/bin/rm: Arg list too long I am trying to write this script but not working. ... (4 Replies)
Discussion started by: samnyc
4 Replies

8. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

9. UNIX for Advanced & Expert Users

Zip million files taking 12 hours or more

Hi I have task to zip files based on modified time but they are in millions and it is taking lot of time more than 12 hours and also eating up high cpu is there any other / better way to handle it quickly with less cpu consumptionfind . ! -name \"*.gz\" -mtime +7 -type f | grep -v '/.*/' |... (2 Replies)
Discussion started by: reldb
2 Replies
DPNS-MKDIR(1)							DPNS User Commands						     DPNS-MKDIR(1)

NAME
dpns-mkdir - make DPNS directory in the name server SYNOPSIS
dpns-mkdir [-m mode] [-p] path... DESCRIPTION
dpns-mkdir creates the specified DPNS directories in the name server. This requires write permission in the parent directory. The owner ID and group ID of the new directories are set to the requestor's real user ID and group ID, respectively. path specifies the DPNS pathname. If path does not start with /, it is prefixed by the content of the DPNS_HOME environment variable. The dpns-mkdir command has the following options: -m specifies the mode to be used. Default mode is 777. -p creates all the non-existing parent directories first. The mode set for the created intermediate directories is the logical differ- ence between 0777 and the user umask but at least 0300. EXIT STATUS
This program returns 0 if the operation was successful or >0 if the operation failed. SEE ALSO
Castor_limits(4), dpns_chmod(3), dpns_mkdir(3), dpns_umask(3) AUTHOR
LCG Grid Deployment Team DPNS
$Date: 2001/10/04 12:12:54 $ DPNS-MKDIR(1)
All times are GMT -4. The time now is 11:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy