Consistency Beats Intensity: Finance, Part II

In the first part of this article, we have said that success is not a result of sudden events or “accidents” but the accumulation of small and seemingly unimportant actions performed over a period of time. These small positive actions when applied to our financial situation can reap great benefits in the future as evidenced by the compounding effect.

However, compounding also has a dark side to it, which can result in great losses instead of great benefits if it is allowed to accumulate over time.

read more

Consistency Beats Intensity: Finance, Part I

If you are like most people, myself included, you have set goals and things that you want to achieve. However like most of us these goals are sometimes not realized and we wonder why. We find it hard to push through our goals and thus give up eventually.

My take on why this happens is: we do not achieve our goals because we are not consistent. Even if we work towards something, we lack the follow-through actions and eventually lose our target and motivation. After studying resources about this behavior, I came into this realization:

read more

The Mirage of “Free Time”

The Mirage of “Free Time”

I consider myself an introvert. As an introvert, I am supposed to be “recharged” when I am alone. So when I was given a chance to be at home alone for a week, I was excited. Finally, one whole week of me having my own time and being able to do the things I wanted to do!, I said to myself.

I thought of the things that I can do for the week, I can:

  • write articles for my blog
  • play the ukulele again
  • work on my side project
  • clean the house more thoroughly

And so at the start of the week I was excited at all those things on my mind. However, I still have a day job and so all of these plans needed to go before and/or after my work hours.

read more

Manage your logs using Logrotate

You have finally set up your own server and your application using this guide, and you feel proud that your app is now running in the vast web. A few days later, when you accessed your application’s URL, you are greeted with a Server Not Responding error! In panic, you SSH into your server to see what is going on, and soon find out that you have just run out of disk space.

What happened?

Most likely the reason is that your log files grew larger and larger as your application is running and it started eating through the entire disk. A couple of possible reasons are:

  • There is a background process that runs database queries every set amount of time, and those queries get logged
  • Using a background queue such as DelayedJob that continuously logs debug messages into the log file
  • Malicious scrapers and bots that repeatedly attempt to gain admin access to your application (by using common login paths such as those used in WordPress, etc)
  • Unnecessary logging of events that have large contents (e.g. logging entire objects or entire request data)

To prevent this scenario we need a way to make sure our logs are cleaned up automatically, so we don’t need to manually remove old logs as they have a tendency to be forgotten. One popular tool for this is a program called logrotate.

Logrotate works by making sure that your log files don’t grow in size unchecked. It compresses the log file and labels it with a timestamp so you can go back to older log files, while keeping the current log file contents only within the specified time range. For example, it can compress and archive logs at the end of the day every day so you begin with a fresh log file at the start of each day.

Installation

Let’s start by installing it, here we assume that we are using Ubuntu or any Debian-based system.

sudo apt-get update
sudo apt-get install logrotate

System Configuration

Logrotate’s configuration file can be found in /etc/logrotate.conf. Modify it using your preferred text editor.

sudo nano /etc/logrotate.conf

By default you will see something like this:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

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

# uncomment this if you want your log files compressed
# compress

This is the system or overall setting of logrotate. It is not recommended that we actually modify this file (although you can if you wish) and it is best practice to use specific configuration files for each log file we want to rotate/archive.

Custom Configuration

The custom configuration files are placed in the /etc/logrotate.d directory. We create a separate file for each log type so it is easier to modify and manage. For example, here is a configuration for rotating Nginx logs:

Start by creating the custom configuration file called “nginx”

sudo nano /etc/logrotate.d/nginx

The contents of the file looks like:

/opt/nginx/logs/access.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
copytruncate
}

/opt/nginx/logs/error.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
copytruncate
}

read more

Reignite Your Finance

When was the last time you have looked at your expenses this month? How much are you saving per year? Do you pay all your bills and debts on time? Do you have investments years ago that you have forgotten about? The new year can be a good time to reflect on how you are doing with your finances and to see if it has turned cold in some way. If it has, then maybe it is time to reignite your passion about handling your finances well. This is my story on how I regained my passion on personal finance after almost a decade.

read more