Operating System - HP-UX
1829403 Members
1908 Online
109991 Solutions
New Discussion

prevent file size is too large

 
SOLVED
Go to solution
peterchu
Super Advisor

prevent file size is too large

We have EDP members will do some testing job in my system , but sometimes these process will generate some error to the system log or any file ( usually the members don't know the log is reached to this level ) , then make the system crashed , could suggest the way how can to prevent this problem ? eg. restrict the file size . thx
8 REPLIES 8
Paul_481
Respected Contributor
Solution

Re: prevent file size is too large

Hi Peter,

You can set the filesystem options to nolargefiles if your problem is largefiles. If you have OnlineJFS you can do this online.

#fsadm -F vxfs -o largefiles /

Hope that helps.

Regards,
Paul
peterchu
Super Advisor

Re: prevent file size is too large

thx reply ,

if I am not mis-understand your solution , the system can't generate any file to a limited size ( eg. 2G ) , but i don't want that , I just want to restrict some specifc file size not all files , can I do that ? thx
Paul_481
Respected Contributor

Re: prevent file size is too large

Hi peter,

If the logs generated is not important you can try to cron a script that deletes the files.

cat /dev/null > logfile

or you can cron a script that rename/move the file to another filesystem.

mv logfile /newdir/logfile.old

Regards,
Paul
peterchu
Super Advisor

Re: prevent file size is too large

thx reply again , the log is important,
but my problem is the log size is increased when the user is testing something , so the log will be increased very fast , I want to limit the size to prevent the system crash suddenly when the log size become too large ( when we are unatteded ) .
thx
Paul_481
Respected Contributor

Re: prevent file size is too large

Hi Peter,

What filesystem is the log located? is it in the / filesystem?

I am running out of suggestions, I hope the guru's have better idea.

Regards,
Paul
peterchu
Super Advisor

Re: prevent file size is too large

thx Paul C. Castillo , help ,

the size will be increased until system full within 1 hour (some testing program will generate unlimited files to the system), so I think I can't move it or delete it before system is crashed . thx
Keith Bryson
Honored Contributor

Re: prevent file size is too large

Hi Peterchu

Your best bet would be to run an occassional cron script that would mv and gzip the file (an ascii log should zip-up to small size). Then re-touch the logfile. A ksh example follows:

#!/bin/ksh
DATE=`date +%m%d%H%M`
mv /location/mylogfile /location/mylogfile.$DATE
touch /location/mylogfile
gzip /location/mylogfile.$DATE

Keith
Arse-cover at all costs
Andrew Fong
Advisor

Re: prevent file size is too large

I am just wondering if disk quota can help you. man quota and edquota.

Regards
Andrew
How are you ?