Use shellSYslog log file write information
ApplicationProgramUse S The log file (in the/var/log directory) That yslog sends messages to the Linux system ). S Ysklogd provides two System Tools : One is System Log Record , The other is kernel information capture. Most programs usually use the C language or S Yslog application or library to send S Yslog message.
1. the logger command is a shell command (interface ). You can use the syslog System Log Module to directly write a line
check the differences between the two methods, we found that nginx_0.6.35-0ubuntu1_i386.deb files mainly have the following file copy process sudo dpkg-l nginx /. /usr/sbin/nginx/usr/share/doc/nginx/changelog.gz /usr/share/doc/nginx/readme/usr/share/doc/nginx/Copyright/usr/share/doc/nginx/news.debian.gz/usr/share/doc/nginx/changelog.debian.gz /usr/share/man/usr/share/m An/Man1/usr/share/man/Man1/nginx.1.gz/etc/nginx/sites-available/default/etc/ nginx/sites-enabled/etc/nginx/CONF. d/etc/nginx/fa
Deploy the log server with rsyslog in Linux record history and send it to rsyslog server, linuxrsyslog1. syslog service Introduction
Rsyslog is a multi-thread enhanced version of syslogd. Rsyslog is responsible for writing logs, logrotate is responsible for backing up and deleting old logs, and updating log filesLogger command
To write custom information to the local log system, use the: logger command.
Logger is a shell command interface that can be
1. Put the following content to the end of/etc/profile (some systems such as CentOS 5.5 may need to end with/etc/bashrc)
HISTFILESIZE = 2000 HISTSIZE = 2000 exportHISTTIMEFORMAT = "% Y % m % d-% H % M % S:" exportPROMPT_COMMAND = '{command = $(history1 | {readx y; echo $ y ;}| cut-d ":"-f2-); logger-p local1.notice-t bash "$ command (user = $ USER, ppid = $ PPID, from = $ SSH_CLIENT, pwd = $ PWD) ";} 'readonlyprompt _ COMMAND
Note: readonly PROMPT_COMMAND prevents malicious normal users from c
-358.23.2 Mon Dec 2 18:56 – 19:20 (00:23)runlevel (to lvl 0) 2.6.32-358.23.2 Mon Dec 2 18:56 – 18:56 (00:00)leni tty1 Mon Dec 2 18:42 – down (00:00)
You can see that there are two running levels. The entry for running level to lvl 3 means that the system runs in the full Console mode, not in X window or GUI. At the same time, when the system is shut down, it is actually switched to the running level 0, which is why the last to lvl 0 is displayed.
View logon failures
The last command records S
/maillog: the log information generated by the mail system
/Var/log/secure: user login information log
2. Logs need to be rolled:
After a period of time, rename the message as message1. and create a new message to store logs.
Logrotate: Use this command to slice log files
/Etc/cron. daily/logrotate
Configuration File:/etc/syslog. conf
The configuration file is defined in the format of facility. priority act
Command to view information of all logged-on usersLastlogThe accton command is used to monitor commands that have been used during user logon, but is only monitored when enabled. UsageStep 1: Enable user behavior monitoring in accton/vat/account/pacctStep 2: lastcomm -- user root check the commands used by the root userStep 3: Disable the monitoring service.5: actively add logsYou can use the logger command to manually add logs to a log file. Script maintenance can be used to mark logs.Log mana
version will be integrated into the main branch of PHP. Compared with Spawn-FCGI, PHP-FPM has better control over CPU and memory, and the former is easy to crash and must be monitored with crontab, while PHP-FPM has no such troubles.
PHP5.3.3 has already integrated php-fpm and is no longer a third-party package. PHP-FPM provides a better way of PHP process management, can effectively control the memory and process, can smoothly load PHP configuration, than spawn-fcgi has more, so PHP officially
patch it to your PHP source code before using it after compiling and installing PHP.
Now we can download the source code tree in the latest PHP 5.3.2 to directly integrate the branch of the PHP-FPM, it is said that the next version will be integrated into the main branch of PHP. Compared with spawn-fcgi, PHP-FPM has better control over CPU and memory, and the former is easy to crash and must be monitored with crontab, while PHP-FPM has no such troubles.
Php5.3.3 has already integrated PHP-FPM a
static files. BecauseLogrotate compresses old logs. Therefore, you need to modify the logrotate setting so that logs are not compressed.Modify VI/etc/logrotate. d/nginx
/Var/log/nginx/* log {daily rotate 10 # retain the 10-day log missingok logs empty nocompress # Here the default value is compress compressed log sharedscripts postrotate [! -F/var/run/nginx. pid] | kill-usr1 'cat/var/run/nginx. PID 'endsc
Squid is compressed once every 5 days by default. It is set in/etc/logrotate. d/squid. If you modify the log location,
Modify/etc/logrotate. d/squid
/Home/log/squid/access. Log {WeeklyRotate 5CopytruncateCompressNotifemptyMissingok}/Home/log/squid/cache. Log {WeeklyRotate 5CopytruncateCompressNotifemptyMissingok}
/Home/log/squid/store. Log {WeeklyRotate 5CopytruncateCompressNotifemptyMissingok# This script
tfile-2016-08-25-08-14-368: copy the files starting with "p" in the/etc directory and ending with non-numbers to the/tmp/mytest1 directory.[Root @ localhost ~] # Mkdir/tmp/mytest1[Root @ localhost ~] # Cp-r/etc/p * [^ [: digit:]/tmp/mytest1/[Root @ localhost ~] # Ls/tmp/mytest1/Pam. d passwd-pki plymouth Uth pm popt. d postfix ppp prelink. conf. d printcap profile. d protocols9: Copy all directories and files ending with. d in the/etc directory to the/tmp/mytest2 directory.[Root @ loc
-cgi/usr/local/php/sbin/php-fpm{start|stop|quit|restart|reload|logrotate}--start Start PHP fastcgi process--stop Force terminate PHP fastcgi process--quit smooth termination of PHP fastcgi process--restart Restart PHP fastcgi process--reload Re-smooth loading PHP php.ini--logrotate re-enable log fileFeatured FeaturesAll of these features are implemented in a "no-break" manner. That is, if you do not use the
Configuration file/etc/logrotate.confDailyThe rotation cycle of the log is dailyWeeklyThe rotation cycle of the journal is weeklyMonthlyThe rotation cycle of the log is monthlyRotate DigitalThe number of log files keptCompressLog rotation when old logs are compressedCreate Mode owner GroupCreate a new log, specifying the permissions of the new log with the owner and the owning groupMail addressThe output is sent by mail to the specified email address when the log rotation isMissingokIf the log d
startlogrotate. logrotate program daily by Cron Starts at the specified time (/etc/crontab). Reference diagram4.1. Logrotate configuration file#cat/etc/logroate.confWeekly # clean up log files once a week Rotate 4 # save four rotation logs Create # Create a new empty log file while clearing the old log Dateext # rollback file with a suffix of date # can go to/var/log look under th
When making a MongoDB shard, when the MONGOs routing service is enabled, we specify a location for the log to be stored:MONGOs--configdb 127.0.0.1:27019--logpath/var/log/mongodb/mongos.log--pidfilepath/var/run/mongodb/mongos.pid-- Logappend--logrotate Reopen--forkAbove we specify the location of the log in the/var/log/mongodb/mongos.log file, when the system data volume is large, after a long run time, the Mongos.log file will become a few g size, whi
Logrotate to cut logs and so on;After some toss, after filling a lot of pits, finally successfully completed the deployment of a new environment, feeling very good.
Below, this is the entire installation configuration process:1. Install Common toolsYum install-y vim wget unzip screen tree mlocate
2. Install the Compilation toolYum install-y gcc gcc-c++ autoconf patch CMake Automake
3. Install Epel WarehouseYum Install-y http://dl.fedoraproject.org
monitored with crontab, and PHP-FPM does not have this annoyance.PHP5.3.3 has integrated php-fpm, no longer a third-party package. PHP-FPM provides a better way to manage the PHP process, can effectively control memory and process, can be smooth overloaded PHP configuration, more than spawn-fcgi has more advantages, so by the official PHP included. The PHP-FPM can be turned on with the –ENABLE-FPM parameter when the./configure.Using PHP-FPM to control the fastcgi process of php-cgi/usr/local
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.