Blog / Howto

How to sync the date and time to a time server in Ubuntu Linux (command line)

June 16, 2011

I just logged in to my Rackspace hosted virtual server running Ubuntu Linux 10.04 and noticed that the time drifted almost a couple of minutes.

Type in the command below to sync your server’s date and time to a time server (where ntp.ubuntu.com is the time server):

sudo ntpdate ntp.ubuntu.com

To automatically correct the time drifting issue in the future, you could also install the ntp daemon:

sudo apt-get install ntp

How to set the proxy settings in Windows via command line

June 11, 2011

Once in a while I need to download and install Python packages at work and having switched to Linux (Ubuntu) at home, I find it quite annoying now to have to go to a website, download the package I need, then manually install.

Fortunately, the pip installer works for Windows as well, allowing the installation of Python packages automatically with a simple command (pip install package_name). But at work, we’re behind a proxy …

How to convert a Java keystore (JKS) to PEM format

May 8, 2011

I’m currently working on a new project where I need to write a service to serve static files to users. Our web application currently runs on Tomcat alone as we don’t have many users (internal users only) and most of the content is dynamic. But with this new project it just seems to make sense to put an Apache web server in front of Tomcat and use the mod_xsendfile module to serve the files, which …

How to import data from a CSV file into a PostgreSQL database

April 19, 2011

I was working on my personal project last week and needed to import some data in CSV format to a PostgreSQL database. I wanted only certain fields to be imported so I had to specify this in the command. I’m new to PostgreSQL so it took me quite a bit of Googling to figure out exactly how to do this.

Here’s how I did it on Ubuntu 10.04 LTS, ‘glucosetracker’ is the name of my …

How to log to multiple log files with log4j

March 6, 2011

Back to Java coding!

We have a Java application that calls an external application and since it gets called quite often we figured we should probably log its standard output and standard error streams to a separate log file so we could easily locate issues with it later. This would also allow us to create a different message format for it and different handlers.

Luckily, it turned out that this is pretty easy to do …