Unable to list files in a directory


 
Thread Tools Search this Thread
Operating Systems Solaris Unable to list files in a directory
# 1  
Old 03-31-2015
Unable to list files in a directory

Hi have a system running solaris with a mount point running 58% capacity used, but unfortunately when I type
Code:
ls -lrt

in a specific directory, it returns:
Code:
ls: Not enough space

. I suspect there are millions of files in this directory.
So what I did is to create a script like this:
Code:
touch -mt 201503040000 /var/tmp/ref1
touch -mt 201503092359 /var/tmp/ref2
find /directory/subdirectory -type f \ ( -newer /var/tmp/ref1 -a ! -newer /var/tmp/ref2 \) -exec rm {} \;

The script apparently runs, because does not return any error, but the free space on that subdir does not increase, or nothing appears to change.

Any help will be appreciated
# 2  
Old 03-31-2015
Check your free inodes and also your swap space...
# 3  
Old 03-31-2015
Quote:
Originally Posted by fretagi
Hi have a system running solaris with a mount point running 58% capacity used, but unfortunately when I type
Code:
ls -lrt

in a specific directory, it returns:
Code:
ls: Not enough space

.
Not enough space to sort the results, probably. find, as you've discovered, can cope because it doesn't sort at all.

Try -exec echo instead of -exec rm to see if any files are matching at all.
# 4  
Old 03-31-2015
List the files with
Code:
find . -ls

# 5  
Old 03-31-2015
Try

df -g mountpoint

Code:
df -g /local
/local             (/local            ):         8192 block size          1024 frag size
528718676 total blocks  242831070 free blocks 237543884 available       31810688 total files
31649815 free files     30933022 filesys id
     ufs fstype       0x00000004 flag             255 filename length

You want to see how many files are on the filesystem and how many free inodes (file slots). This bypasses all directories. Your directory is either "broken" which means it is fsck time, or your directory has waaay too many entries.

Last edited by jim mcnamara; 03-31-2015 at 11:48 PM..
# 6  
Old 04-01-2015
Hi

Thank you for the replies, the
Code:
df -g /mount point

, produce me the follwoing results
Code:
 df -g /opt/optima
/opt/optima        (/dev/dsk/c0t0d0s4 ):         8192 block size          1024 frag size
174504966 total blocks   74857050 free blocks 73112002 available       10500672 total files
  503155 free files      8388620 filesys id
     ufs fstype       0x00000004 flag             255 filename length

the
Code:
find. ls

does list the files slowly.... and they are
Code:
csv

extension.
They want me to delete all march files...

swap space:
Code:
 swap -s
total: 256344k bytes allocated + 34752k reserved = 291096k used, 12758600k available

and
Code:
 swap -l
swapfile             dev  swaplo blocks   free
/dev/dsk/c0t0d0s1   32,9      16 20975120 20975120

# 7  
Old 04-01-2015
A ufs filesystem becomes exponentially slow with the number of files per directory.
As a rule of thumb, do not have more than 10000 files per directory!
If this is Solaris 10, zfs would be the better alternative for such a work load.
Your method works, and can be augmented with a -ls to show what's being deleted.
Terminate the -exec rm with a +, that reduces the numbers of forks, i.e. is more efficient. In effect it does
rm file1 file2 file3 ... rather than rm file1; rm file2; rm file3; ....
rm might prompt in certain conditions when it sees a terminal. rm -f prevents it.
Code:
find /directory/subdirectory -type f \( -newer /var/tmp/ref1 -a ! -newer /var/tmp/ref2 \) -ls -exec rm -f {} +

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to ssh and list files in local directory from remote.

#!/bin/bash script_work_dir="/home/websys/TEST_dpi_42_file_trnsfer_engine/PORT22/script_work_area" script_config_dir="/home/websys/TEST_dpi_42_file_trnsfer_engine/PORT22/script_config" dpi_sourceServerList=$script_config_dir"/dpi_sourceServerList" dpi_srvr_42="rtm@1.1.1.1"... (8 Replies)
Discussion started by: sadique.manzar
8 Replies

2. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

3. UNIX for Dummies Questions & Answers

Unable to find files, those can be present anywhere in the directory tree,based on its creation date

Hi I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job. Please help (2 Replies)
Discussion started by: sam192837465
2 Replies

4. Shell Programming and Scripting

Unable to list files in ascending order

Hi ! I am just trying to list my files in ascending order so that in some other software, I just want merge with some modification, when I list its coming like this new-10.txt new-11.txt new-12.txt new-13.txt new-14.txt new-15.txt new-16.txt new-17.txt new-18.txt new-19.txt... (2 Replies)
Discussion started by: nex_asp
2 Replies

5. Red Hat

Unable to copy files due to many files in directory

I have directory that has some billion file inside , i tried copy some files for specific date but it's always did not respond for long time and did not give any result.. i tried everything with find command and also with xargs.. even this command find . -mtime -2 -print | xargs ls -d did not... (2 Replies)
Discussion started by: before4
2 Replies

6. Shell Programming and Scripting

Copy list of files from a keyword list to another directory

Hello, I have a folder with a massive amount of files, and I want to copy out a specific subset of the files to a new directory. I would like to use a text file with the filenames listed, but can't get it to work. The thing I'm hung up on is that the folder names in the path can and do have... (5 Replies)
Discussion started by: twjolson
5 Replies

7. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

8. UNIX for Dummies Questions & Answers

unable to list the files

Hi, $ ls -ltr *.log Error : argument list too long: ls How to rectify this ? (2 Replies)
Discussion started by: risshanth
2 Replies

9. UNIX for Dummies Questions & Answers

Unable to view files in a particular directory under /opt

Hi Everybody, I am Unable to view files in a particular directory under /opt. But, when I reboot the server, I am able to view the files.. Its happening daily. Do u 've n e answers/suggestions. Kindly help.. :eek: (1 Reply)
Discussion started by: its.simron
1 Replies

10. Linux

Unable to view files in a particular directory under /opt

Hi Everybody, I am Unable to view files in a particular directory under /opt. But, when I reboot the server, I am able to view the files.. Its happening daily. Do u 've n e answers/suggestions. Kindly help.. :confused: (1 Reply)
Discussion started by: its.simron
1 Replies
Login or Register to Ask a Question