We help IT Professionals succeed at work.
Get Started

How do I use a cronjob to truncate all logs on my Centos 7 server to 1 gig max size?

459 Views
Last Modified: 2016-03-02
I am running a VPS with centos 7 and have several websites sites hosted on it (wordpress, magento, joomla, opencart, corephp). I am looking for a way (cronjob if possible) that can truncate the various error.log and other log files of these sites to a max size of 1 gb each. I am imagining a script that can search for .log files on the server and truncate them at a fixed interval, if it is possible to create such a cronjob (using logrotate?). If not I don't mind setting one cronjob per error.log or whatever.log file if someone here could help me create the cronjob query that can do it.

thanks in advance
Comment
Watch Question
Cloud Architect
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE