Yate Study--./yate/tools/log_rotate.sh

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.