Today see the system space is occupied, and then look at large files, found that Catalina.out has been >60g, there are many solutions online, but still want to learn to write a shell script to deal with, in this record to write content, as well as the problems encountered and processing methods.
Directly on the content:
First: VI, Touch command to create auto-clear-currday-catalina_out-content.sh files, do not forget to give executable permissions: chmod +x Auto-clear-currday-catalina_ out-content.sh;
The second step: SH content is as follows:
##==========start==============##
#!/bin/sh
#auto-clear-currday-catalina_out-content
Cat/dev/null >/usr/local//tomcat7.0/logs/catalina.out
##==========end===============## relatively simple to clear the code;
Part III: I am using Linux crontab Timer task execution shell script, input crontab-e write timing content, as follows:
* * */home/auto-clear-currday-catalina_out-content.sh
Save write;
The problems encountered:
After the third write exit prompt: Errors in crontab file can ' t install. Here is your shell scripting code is wrong, but don't expect to be prompted for more detailed errors, because the need for branch ...
Before modification:
##==========start==============##
#!/bin/sh
#auto-clear-currday-catalina_out-content
Cat/dev/null >/usr/local//tomcat7.0/logs/catalina.out
##==========end===============##
After modification:
##==========start==============##
#!/bin/sh
#auto-clear-currday-catalina_out-content
Cat/dev/null
>/usr/local//tomcat7.0/logs/catalina.out
##==========end===============##