Set Log Rotation

Source from: and


What’s log rotation?

Logrotate is a utility designed for administrators who manage servers producing a high volume of log files to help them save some disk space as well as to avoid a potential risk making a system unresponsive due to the lack of disk space.

In web server, it’s very often to save access_log and error_log on purpose. access_log will help you to check hijack and error_log will help you to locate any error in your web apps.

We will describe log rotation in:

  1. Check if logrotate is running
  2. Config logrotate
  3. Add your log files into logrotate.d

Normally the logrotate will be executed in a daily routine.

so you can find if it’s enabled in /etc/cron jobs

$ ls cron.*

0hourly katello-host-tools sysstat

logrotate man-db.cron mlocate rhsmd




So in our case, it enabled in cron.daily, which means running every day.

Logrotate’s configuration is done by editing two separate configuration files:

  • /etc/logrotate.conf
  • service specific configuration files stored in /etc/logrotate.d/.
cat /etc/logrotate.conf 
# see "man logrotate" for details
# rotate log files weekly

# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
su root syslog

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones

# uncomment this if you want your log files compressed

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    create 0664 root utmp
    rotate 1

/var/log/btmp {
    create 0660 root utmp
    rotate 1

# system-specific logs may be configured here

The main options of logrotate are:

  • weekly: rotates the log files once a week
  • su root syslog: will archive the logs using the specific user (root) and group (syslog) to prevent issues with permissions
  • rotate 4: makes sure that four old versions of the file are saved. Rotates a given log four times before deleting it, so this keeps four weeks of logs online.
  • create: The old file is saved under a new name and a new file is created
  • compress: compress causes logrotate to compress log files to save space. This is done using gzip by default, but you can specify another program
  • include: This important option makes sure that the content of the directory /etc/logrotate.d is included. In this directory, files exist that specify how to handle some individual log files.

You can see for example the logrotate configuration for the apache web server

# cat /etc/logrotate.d/apache2 
/var/log/apache2/*.log {
	rotate 14
	create 640 root adm
                if invoke-rc.d apache2 status > /dev/null 2>&1; then \
                    invoke-rc.d apache2 reload > /dev/null 2>&1; \
		if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
			run-parts /etc/logrotate.d/httpd-prerotate; \
		fi; \

Logrotate contains some additionals options that you can see above:

  • daily: rotates log on basis day
  • missingok: Don’t raise an error if the log is missing
  • delaycompress: Don’t compress the file until it has already been rotated. This is to prevent corruption if the daemon doesn’t close the log file immediately.
  • notifyempty: Don’t rotate the log file when it is empty
  • create 640 root adm: this will create new log files with set permissions, owner and group
  • sharedscripts: If the wildcard matches several files, run any scripts once for all files
  • postrotate/endscript: Specifies some commands or scripts that should be executed until the endscript keyword, after the logs were rotated.
  • prerotate/endscript: as postrotate/endscript, it specifies commands or scripts that should be executed before log rotating begins.

You can have some information about the additional options by using the manual

man logrotate



Posted in Uncategorized | Leave a comment

PDO statement::execute(): MySQL server has gone away

Just in case you have same issue when you deal with big data in Laravel, and try to save the big data into database, you may have same issue.

Original I thought it was time out caused MySQL connection lost, after a couple of round test, I found it’s not because connection lost. (You can use mysql_ping() to test connectivity). The reason is because the data is too big which is out of max_allowed_packet = 2M. Then I changed it to 5M, and now I got another issue:

sqlstate[42000]: syntax error or access violation: 1118 the size of blob/text data inserted in one transaction is greater than 10% of redo log size. increase the redo log size using innodb_log_file_size.

This is because we are using innodb engine, which saved transactions into log file in case you want to rollback the last operation. So the old value of innodb_log_file_size is 5MiB, then I changed to 20MiB, then restart MySQL DB server, the issue is gone.

It’s very interesting that we all thought the server gone away is because connectivity issue, but it’s because we don’t have enough memory of file size settings.

Posted in Uncategorized | Leave a comment

A Work-from-Home Guide to Internet Speed

If your job depends on your home Internet, our bandwidth guide is for you.

Editor’s Note: Frontier Business posted the article below on LinkedIn.

undefinedThere are many reasons why almost 3% of the workforce is spending less time at the office. One study even shows that employees who work from home are actually more productive thanks to fewer distractions from co-workers and a quieter workspace.

To keep up with your workload, though, your home Internet speed needs to be at least as reliable as business Internet. Read our guide below to help determine how much bandwidth you need and compare residential or business service.

Determining Your Current Bandwidth

Bandwidth is the maximum rate at which your computer can receive information from the Internet. Larger files, such as movies, require more bandwidth, while checking your email or working on a Word document uses less.

To determine your current bandwidth, test your Internet speed with an online speed test tool. While your service provider might promise a certain maximum speed, the speed you actually get depends on the number of devices that connect to the Internet at the same time, the types of activities you do (word processing, video conferencing, chatting with clients, etc.), and cloud and storage needs.

In most cases, Internet connections download much faster than they upload, since most online activity involves your computer receiving information from the Internet. Upload speeds tend to be slower because sending emails and posting on social media don’t require a lot of bandwidth, but depending on your specific needs you could require a faster upload speed.

Calculating How Much Bandwidth You Need

If you work from home and are considering adjusting your Internet service, you’ll first need to calculate how much bandwidth you actually need.

For example, you wouldn’t want the most elite business Internet service plan if you live alone and work from home during the day. But if you have a family, factor them and their online activities into your bandwidth needs.

Opting for Residential or Business Internet

Residential Internet will probably be enough if you use your home as a satellite office, but you may have to deal with speed lags throughout the day because some residential lines are shared with your neighbors to keep the overall cost down, be sure to check with your local service provider. If you’re a small-business owner, you may want a dedicated business line so you’ll have a consistent connection around the clock.

Another perk to a business line is some Internet Service Providers (ISPs) offer service-level agreements (SLAs) that can guarantee a certain level of performance, as well as compensation if the service doesn’t meet that level. ISPs may also offer small business-owners Virtual Private Networks (VPNs), data backup, security, and Wi-Fi network setup for an additional fee.

Some companies require their remote workers to connect their home computers to a VPN—a private network that allows you to share data securely. If your employer hasn’t provided a computer with an already-established VPN, you may want to think about that feature when you’re deciding between residential and business Internet for your home.

Choosing Your Internet Service Provider

Now that you’ve figured out how much bandwidth you need and whether you want residential or business high-speed Internet service, how do you choose a provider? Consider the following tips:

  • Make sure they offer high-speed Internet. The faster your Internet connection, the better—especially when you’re working on a deadline.
  • Compare prices based on download and upload speeds. Not all companies use the same unit of measurement for speeds (i.e., 60 Mbps is not the same as 60 Gbps).
  • Pay attention to contract terms. If you’re working from home short term, you may not need a year-long contract. Some ISPs offer month-to-month options, while others will charge you a fee for canceling service before your contract ends.
  • Ask about add-ons and fees. Business customers may get some added perks with their service plans, but even if you decide to go with a residential plan, ask about any additional benefits or fees. For example, some providers charge a one-time or monthly fee for the router, and some offer free virus protection or website hosting.

In the end, it just takes a little research into Internet speeds, and you can get as much work done at home as you do in the office—if not more!

Posted in Uncategorized | Leave a comment

Why we lost 1M people?

Today is March 28, 2019, When I open the page, I found US population decreased again, that’s good news or fake news??

I pulled my last saved screen shot on Dec 04, 2018, the population number is 329,114,356.


So I use select a date to search the US population on Dec 04, 2018, the population number is only 328,096,801, we lost over 1 Million people!!


I don’t know how to explain this: on the same day the data difference is 1 million? which number I should trust on earth?

Posted in Uncategorized | Leave a comment

Linux grep command

Sometimes, we need grep a string with slash/ or backslash\, like we want to know where we called this model “use App\Models\Users” in the code.

First, I tried grep -rils “Models\\Users”, nothing returned;

Then I tried grep -rils “Models/\Users”, still nothing returned;

Very occasionally, I tried grep -rils “Models\\\Users”, it returned results as I expected.

Posted in Computers and Internet | Leave a comment

Digital Tranformation

Image | Posted on by | Leave a comment


说句老实话,第一遍看的时候,的确有些懵,但看第二遍的时候,随着很多细节的发掘,和前后情节的贯穿,明白了张艺谋想要表达的令你扑朔迷离的影子替身的故事,明白了表面的棋子和背后的棋局之间的道理。后来又花时间看了纪录片《张艺谋和他的影》,更加理解了张艺谋对电影的执着,追求完美严谨的呈现,所有道具,布景都一丝不苟。而且张艺谋的每一部电影都不重复,都在追求新的尝试,既然是有新的尝试,就一定会有失败和成功。在《影》这部电影中,我看到了成功,色彩运用的成功,演员表演的成功, 专业团队合作的成功。也许你看到只是两个小时的电影,但是这个屏幕背后所有人的付出,精益求精的态度,让你非常感动。我们看到的《影》是一部视觉和情节都超越了好莱坞的优秀电影作品。





Posted in Movies, Uncategorized, 兴趣 | Leave a comment