Skip files in use


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Skip files in use
# 1  
Old 08-29-2012
Skip files in use

Hi all,
i'm trying to configure a script that will find and gzip the searched files,
this is easy enough,
Code:
find /var/log/myfolder/*.log -type f -mtime +1 -exec gzip {} \;
cd /var/log/myfolder/
mv *gz myzipped_folder/

but what it would be very handy is to skip the files in use,because tomcat its going to check for some file that my script have gziped and move and alerting me by email for not enough space on HDD,when in reality there is enough,
you may suggests why don't you simply restart Tomcat,well i cant do that,to many jobs running 24h to 24h,so is any way to implement on my script the option skip files in use by Tomcat?

Thanks in advance
Charli.
# 2  
Old 08-29-2012
If you can't get a short downtime to wrap that file, reducing the log level or adding more space to the filesystem might be an option.
Also logrotate is said to be able to truncate open log files. Never tried that but maybe worth trying it.
# 3  
Old 08-29-2012
Quote:
Originally Posted by zaxxon
If you can't get a short downtime to wrap that file, reducing the log level or adding more space to the filesystem might be an option.
Also logrotate is said to be able to truncate open log files. Never tried that but maybe worth trying it.
Thanks for the reply,
yes i already have
Code:
logrotate

for some log files,i wanted to implement this script now,till i configure all of the log files with logrotate,because the log files are really tons of them,so with a script it wil solve the issue temporarily,and give me the needed time to configure out logrotate.
Any suggestions?
# 4  
Old 08-29-2012
You could build the list of files you want you get with find, but instead of executing the gzip, redirect the output to a temporary file, have a second list which works as your exclude, use something like a
Code:
grep -vf exludelist.txt outputofthefindcommand.txt

and decide by this to compress them or not.
# 5  
Old 08-29-2012
Quote:
Originally Posted by zaxxon
You could build the list of files you want you get with find, but instead of executing the gzip, redirect the output to a temporary file, have a second list which works as your exclude, use something like a
Code:
grep -vf exludelist.txt outputofthefindcommand.txt

and decide by this to compress them or not.
i cant use an exclude list as the files in use aren't always the same,
they always change.
# 6  
Old 08-29-2012
Listing files opened by a process is difficult as this can be very transient info, but
Code:
lsof -c tomcat

should list those files tomcat actually acts upon.
# 7  
Old 08-29-2012
Quote:
Originally Posted by RudiC
Listing files opened by a process is difficult as this can be very transient info, but
Code:
lsof -c tomcat

should list those files tomcat actually acts upon.
any suggestion on how to implement this on my script,and to skip the printed files?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can I skip files when running rm command

Platform: Oracle Enterprise Linux 6.2 I have several files like below. I want to remove all files except one file For example , I want to remove all the files below except dasd_91197.trc $ ls -alrt *.trc -rw-r----- 1 ecmdev wms 8438784 May 7 21:30 dasd_91177.trc -rw-r----- 1 ecmdev wms ... (3 Replies)
Discussion started by: John K
3 Replies

2. Shell Programming and Scripting

Skip first and last line

Hi All I have a sample file like below: 012312112 1372422843 1236712 1372422843 1275127 3109301010 from which I wan't to: 1.)delete... (10 Replies)
Discussion started by: swasid
10 Replies

3. Shell Programming and Scripting

How to skip copying some types of files in csh

Hi, I want to copy data from one directory to another in csh script. But in that i want to skip certain types of file. How can i do that. Currently i am copying all the files as mentioned below.. foreach d ( $TEST_PATH/*) cp -R $d $PWD end now i want to skip files... (3 Replies)
Discussion started by: vdhingra123
3 Replies

4. Shell Programming and Scripting

Skip first and last n records with awk

Hi, I have an awk code that reads an input file, checks the 4th column and tells if its fine. #!/bin/ksh { if ($4 == 0) print "fine" else print "some problem" }' FILENAME My problem is that, I dont want to check the first 3 and last 3 lines. This can be hard coded by using BEGIN and END... (9 Replies)
Discussion started by: gotam
9 Replies

5. Programming

How to skip getchar in C?

Hi, I would like to read an input from keyboard using getchar. However, if no input (No Carriage return/new line none whatsoever) is given after say, 5 seconds, I would like to skip the getchar and move on. How do I do this in C. I'm using GNU compiler set. Thanks, (5 Replies)
Discussion started by: cprogdude
5 Replies

6. Shell Programming and Scripting

go to / skip in script

Hi all I have some script like this #!/bin/bash mv /tmp/file1 tmp/file2 if ] ; then cp /tmp/filetest/ tmp/file3 if ] then echo "succes" else echo "failed" fi else echo "failed" fi i didn't try to see if it's work, the thing is that i don't care if... (4 Replies)
Discussion started by: naamas03
4 Replies

7. Shell Programming and Scripting

extract multiple cloumns from multiple files; skip rows and include filenames; awk

Hello, I am trying to write a bash shell script that does the following: 1.Finds all *.txt files within my directory of interest 2. reads each of the files (25 files) one by one (tab-delimited format and have the same data format) 3. skips the first 10 rows of the file 4. extracts and... (4 Replies)
Discussion started by: manishabh
4 Replies

8. SuSE

skip upgrading rpm

hi the step 'upgrading the rpm' is taking a long tme. and since I am not interested in uninstallation, is there a way to skip this step? thx (4 Replies)
Discussion started by: melanie_pfefer
4 Replies

9. Shell Programming and Scripting

Skip new line

Hi, how can I skip the new line of echo? In SH!!!! echo "the date is :" date and result I want is the date is : Tue Oct 11 22:24:37 WEST 2005 I've already tried including the \c inside the echo, but it didn't work. Thanks! (2 Replies)
Discussion started by: pmpx
2 Replies

10. BSD

FreeBSD skip UserConfig...

When I boot FreeBSD from cd/floppy, it skips the UserConfig program. I have no idea why! And if I skip this step, my hardware won't work. ( I already tried...) Can anyone help me with this??? (2 Replies)
Discussion started by: Enoch Chan
2 Replies
Login or Register to Ask a Question