Checking files size and deleting if bigger than x


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Checking files size and deleting if bigger than x
# 1  
Old 07-30-2008
Checking files size and deleting if bigger than x

Hello ,
I have to write a crontab line make a check on a file and, if bigger than 2Gb, to stop apache daemon, delete the file and restart apache .
Someone have suggestions ?
Thanks
# 2  
Old 07-30-2008
check the -size option of find command
# 3  
Old 07-30-2008
Hammer & Screwdriver here is a start

Code:
find / -size +2000000c 2>/dev/null -exec ls -l {} \;

This would find files over 2M; change as appropriate to do 2G.
Unclear on exact next steps; perhaps you will direct this output to a work file, and then analyze that work file for the rest of you requirements:
(a) delete certain files; beware, you may not alwys want to delete files
(b) stop & start the daemons
(c) etc...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Can not send files bigger than 1350 bytes

I am sending files over WAN from Ubuntu 8 to OSR 5.07 on regular basis without a problem using ftp and rsync. Today I can not send anything bigger than ~1350 bytes, tried ftp, rsync, scp, it becomes frozen and I have to kill the process. Smaller files are sent without issue. Telnet and ssh... (1 Reply)
Discussion started by: migurus
1 Replies

2. Shell Programming and Scripting

Checking the total size of all files from a particular date

Hi I have some set of files for a particular date. What is the command that I need to put in for finding the total size of all the files for that particular date. The following command is fetching me the size of all individual files seperately du -h *20101010* 16M file1.20101010 120K... (10 Replies)
Discussion started by: bobby1015
10 Replies

3. Shell Programming and Scripting

zsh compare size pdf and delete bigger?

I have used an script to reduce the size of multiples pdf. This script creates files with the same name but with different extension. The extension of the compressed files is xpdf. Sometimes the "compressed" xpdf are bigger than the "uncompressed"pdf. I want to create a zsh script to compare each... (1 Reply)
Discussion started by: AMDx64BT
1 Replies

4. Shell Programming and Scripting

deleting all files with 0 size

I tried with find . -maxdepth 1 -type f -size 0 | xargs rm -f but, getting the error find: bad option -maxdepth seems maxdepth is not there in my system. m using HP-UX Please help. (7 Replies)
Discussion started by: gotam
7 Replies

5. Shell Programming and Scripting

Deleting files based on their size

I have several files in a folder and I would like to delete the ones that do not contain all the required information (size) let say 1kb. Any ideas? (4 Replies)
Discussion started by: Xterra
4 Replies

6. Shell Programming and Scripting

sort files by date, delete oldest, if total size bigger than

hello people i need your help please i want to achieve the following with the simplest, most efficient shell-tools: i have a directory with a lot of files from users. the script should check which partition the dir is on if the partition with the directory is more than 90% full ... (2 Replies)
Discussion started by: scarfake
2 Replies

7. Shell Programming and Scripting

how can i print the output of the shell script in bigger size

how can i print the output of the shell script in bigger size eg: echo " hello world" i want to print this in the output with bigger size in the middle of the screen. can someone please help me out in that (2 Replies)
Discussion started by: mail2sant
2 Replies

8. Shell Programming and Scripting

finding files bigger than 2G

find /base/directory -size +2048M > /tmp/tempfile 1] is there an option to specify the size in Gb 2] the output lists files with size such as: 1152157 (doing ls -l so I guess it is in bytes) So I am missing something here because this file has a size below 2 Gb. Any hints?? thx. (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

9. AIX

How to tar a files that bigger than 2 gig in AIX 5.2?

Hi, I have a question. Im trying to tar a files that the size is bigger that 2 gig. When i tried to tar it, i got an error says "eached end-of-file before expected" How can i solve this? Thanks and Regards (6 Replies)
Discussion started by: owangecounty
6 Replies

10. Shell Programming and Scripting

Checking the last line and deleting

Hi everyone, I have a file. I have to search whether the last line is empty(blank line) or not. if it is a blank line, I have to delete it. I dont want to move it to a temp file and again to original file after deleting the last line because I am doing some more modification in that file. Just I... (3 Replies)
Discussion started by: srivsn
3 Replies
Login or Register to Ask a Question