Script to check file size

General support questions
Post Reply
carancanfunfa
Posts: 4
Joined: 2015/02/10 17:24:11

Script to check file size

Post by carancanfunfa » 2015/03/26 14:14:01

Hello, we have a server in which a certain file keeps growing in size until it makes the server to crash down.
I want to know if it is possible to make a script that constantly checks the file size and send some kind of alert once it gets a certain size. The alert could be a banner at login or an email sent to some administrator.
Do you think it is possible?

jscarville
Posts: 135
Joined: 2014/06/17 21:50:37

Re: Script to check file size

Post by jscarville » 2015/03/26 14:22:22

Start with:
$ stat /path/to/file -c %s

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Script to check file size

Post by gerald_clark » 2015/03/26 14:31:57

What file?
If it is a log file, use logrotate.
If it is not a log file, a simple cron job should be able to do what you want.

Post Reply