Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

How to restrict the maximum size of single file can be opened

Senthil_N
Advisor

How to restrict the maximum size of single file can be opened

Hi All,

 

There is only Linux server where swap is configured with 8gb. one day some one opened a log file (size is more than 8gb) using vi editior. the server got hung. we would like to prevent same kind of issue happening again. So that, I need to know how to prevent one file from opening through vi editor if the file size  is more than 8gb.

1 REPLY
Highlighted
Goran Koruga
Honored Contributor

Re: How to restrict the maximum size of single file can be opened

Hello.

 

You can set data size limit for a process -- man setrlimit.

 

To experiment with it, use shell built-in 'ulimit' to set the limits (typically "ulimit -d").

 

I would also recommend to disable memory overcommit (check kernel documentation, namely "sysctl/vm.txt" file).

 

Regards,

     Goran