How to delete some of the files in the directory, if the directory size limits the specified size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to delete some of the files in the directory, if the directory size limits the specified size
# 1  
Old 02-10-2012
How to delete some of the files in the directory, if the directory size limits the specified size

To find the whole size of a particular directory i use "du -sk /dirname".. but after finding the direcory's size how do i make conditions like if the size of the dir is more than 1 GB i hav to delete some of the files inside the dir
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Sorting files by size in another directory

1. The problem statement, all variables and given/known data: I'm trying to use a directory path to enter a new directory and sort the files there. I'm using the language C with a system call in Unix to sort the files from smallest to largest. 2. Relevant commands, code, scripts, algorithms:... (1 Reply)
Discussion started by: TedFTW
1 Replies

2. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

3. UNIX for Dummies Questions & Answers

How to get the set of files size as a sum in a directory.

Hi, Can someone help me to get the complete files size (sum) over a perod time (1 day,2days)in a directory. eg: Directory :ABC I have a1,a2,a3 files are created in last 24 hours so I need to get the some of all these files. I am using the below find command but its giving me the... (1 Reply)
Discussion started by: gaddamja
1 Replies

4. Shell Programming and Scripting

Delete 2 months before old files when we get alarm directory size > 90%

Please Help me Question: - we manually moving/removing old files, when we are getting alarm as /dir1/dir2 size greater than 90%. we manually moving/removing old files and reduce the file size to less than 90% - I want to delete all 2months before old files once we get the thresh hold >= 90%... (3 Replies)
Discussion started by: piyus
3 Replies

5. Shell Programming and Scripting

Getting the total file size for certain files per directory

Hi, I am trying to get the total file size for certain files per directory. I am using find /DirectoryPath -name '*.dta' -exec ls -l {} \; | awk '{ print $NF ": " $5 }' > /users/cergun/My\ Documents/dtafiles.txt but this lists all the files in the directories. I need the total... (9 Replies)
Discussion started by: cergun
9 Replies

6. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

7. UNIX for Dummies Questions & Answers

Cp files (>5 Mb size) from one directory to another

Hi All, I have a requirement like below, I want to transfer few file of size > 5 Mb from one directory to anotehr directory. Please let me know the command how can i do that Sorry if it looks silly Senthil (6 Replies)
Discussion started by: skcontact
6 Replies

8. UNIX for Dummies Questions & Answers

listing files in a directory in bases of size

Hi , I want to list all files in the order of size . Just want to know which files occupies more size and which occupies less size . Is it possible with ls command ? :) Thanks, Arun. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

9. Shell Programming and Scripting

files of size 0 need to be deleted inside a directory

Hiiii, I have written a script which takes backup of some log files. let say the backuplocation is --- /abc/backuplocation -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt23994.log -rw-r--r-- 1 webmut2 spgroup 0 Jan 27 02:41 ansrpt3601.log -rw-r--r-- 1... (2 Replies)
Discussion started by: namishtiwari
2 Replies

10. Shell Programming and Scripting

How to check if 3 files have same size in directory

I need to determine if any three files have the same file size in a specified directly? I have got as far as listing the file sizes but where to go from here? ls -al |sort -n -r +4 | awq '{print $5}' Thanks in anticipation (5 Replies)
Discussion started by: oggle
5 Replies
Login or Register to Ask a Question
chroot(2)							System Calls Manual							 chroot(2)

Name
       chroot - change root directory

Syntax
       chroot(dirname)
       char *dirname;

Description
       The  dirname is the address of the pathname of a directory, terminated by a null byte.  The system call causes this directory to become the
       root directory (/).

       For a directory to become the root directory, a process must have execute (search) access to the directory.

       This call is restricted to the superuser.

Return Values
       Upon successful completion, a value of 0 is returned.  Otherwise, a value of -1 is returned and errno is set to indicate an error.

Diagnostics
       The system call fails and the root directory is unchanged under the following conditions:

       [ENOTDIR]      A component of the dirname is not a directory.

       [ENAMETOOLONG] A component of a dirname exceeded 255 characters, or an entire dirname exceeded 1023 characters.

       [ENOENT]       The dirname argument points to the name of a directory which does not exist, or to  an  empty  string  and  the  environment
		      defined is POSIX or SYSTEM_FIVE.

       [EFAULT]       The dirname points outside the process's allocated address space.

       [ELOOP]	      Too many symbolic links were encountered in translating the pathname.

       [EIO]	      An I/O error occurred while reading from or writing to the file system.

       [ESTALE]       The  file  handle  given	in the argument is invalid.  The file referred to by that file handle no longer exists or has been
		      revoked.

       [ETIMEDOUT]    A connect request or remote file operation failed because the connected party did not properly respond  after  a	period	of
		      time that is dependent on the communications protocol.

       [EPERM]	      The effective user ID is not that of superuser.

See Also
       chdir(2)

																	 chroot(2)