From the beginning has not yet started to write the server above the code, whether the C/s or b/s are basic contact and achieved, from the beginning of the socket communication, to the transplant boa, realize CGI, groping VoIP server,web server (Php--phalcon), Web server (JAVA-SSH) has been maintained. Contact Yate server time is the longest, but also for the first time a system has a relatively full understanding. Log-run in the background-run scripts-Service installation-Package deployment installation-performance testing.
Today saw the inside of the log section, the implementation of the Mechanism and method than I used to be better, the personal understanding of the post, so as to deepen their understanding of the log it.
The following code is the content of the./yate/tools/log_rotate.sh
# assumes Yate writes To/var/log/yate and/var/log/yate-cdr.tsv# can place this script in/etc/cron.hourly and not us E The system logrotate# Note:files is never deleted! Periodic cleanup is requiredbase= "/var/log" old= "$base/yate-old" ym= ' Date ' +%y-%m ' d= ' date ' +%d ' h= ' date ' +%h ' mkdir-p "$old/$ym/$d" mv "$base/yate" "$old/$ym/yate-$d-$h. Log" mv "$base/yate-cdr.tsv" "$old/$ym/$d/yate-cdr-$h. TSV"/bin/ Kill-hup '/bin/cat/var/run/yate.pid '
First of all, I understand:
Make sure Yate writes logs to/var/log/yate and/VAR/LOG/YATE-CDR.TSV (I'm not using YATE-CDR.TSV)
You can put this script in the/etc/cron.hourly folder (which is a plan that executes every hour under Linux) without using the system's Logrotate (a logging tool for the Linux system)
Log files will never be deleted and will only be cleaned regularly
The meaning of the script is roughly the same, (every hour will be executed)
Base= "/var/log" old= "$base/yate-old"
Defines the directory where old log files are stored/var/log/yate-old
ym= ' Date ' +%y-%m ' d= ' date ' +%d ' h= ' date ' +%h '
Gets the month, day, and hour of the time. such as "2015-04", "22", "19"
Mkdir-p "$old/$ym/$d"
Recursively create directories that hold old log files
MV "$base/yate" "$old/$ym/yate-$d-$h. Log"
MV "$base/yate-cdr.tsv" "$old/$ym/$d/yate-cdr-$h. TSV"
Log files to the old log file name (/var/log/yate-old/2015-04/yate-22-19.log)
/bin/kill-hup '/bin/cat/var/run/yate.pid '
Rerun Yate (/var/run/yate.pid file holds the process number of the Yate process)
Compared to the Linux log tool logrotate effect, it must be to understand the tool first.
If you don't remember the basic usage of this tool.
Posted here a reprint of the blog post, we can see
http://hao360.blog.51cto.com/5820068/1344732
It is more convenient to use log tool logrotate. But this way is more flexible, to see their own needs, the principle is actually the same.
Today just to show you the script part of the dump and rollback, the actual log output in the program.
Yate Study--./yate/tools/log_rotate.sh