vicker313 tech blog

November 26, 2011

Setup CRON job to Trigger an URL

Filed under: Server — Tags: , — vicker313 @ 7:42 pm

The following CRON script can be used to trigger an URL (example below is schedule to run every minute, for other schedule setting please refer to other CRON tutorial).

0 * * * * wget -q -O - >/tmp/cron 2>&1

In Linux, wget is used to download file from internet (or network). -q option means quiet, -O means output file. It is important to put the -O option so that your server won’t end up with annoying CRON output file.

December 23, 2010

Setup SSL Certificate at Tomcat

Filed under: Server, Tomcat — Tags: , , — vicker313 @ 9:12 am

The method here is to implement CA certified SSL certificate in Tomcat Service.

  1. Generate a key store file using keytool utility (installed together with JDK). It will ask for a password to generate the key store file.
    keytool -genkey -alias <any alias name> -keyalg RSA -keystore <output file>
    For example:
    keytool -genkey -alias tomcat -keyalg RSA -keystore tomcat.key
  2. Generate a certificate request file.
    keytool -certreq -keyalg RSA -alias <alias> -file <output file> -keystore <keystore file>
    keytool -certreq -keyalg RSA -alias tomcat -file certreq.csr -keystore tomcat.key
  3. Then submit the certificate request to your CA. Normally you just need to submit the content of the request file.
  4. As a result you will get the content of the certificate. Copy the content and save it as a certificate file (for example tomcat.cer)
  5. For some CA (like Thawte), you need to download the CA trusted certificate from the their website in order to complete the implementation (EV_Root.cer and EV_intermediate.cer)
  6. Finally import the certificates using command below:
    keytool -import -alias <alias name> -keystore <keystore file> -trustcacerts -file <certificate>
    For example:
    keytool -import -alias EV_Root -keystore online.key -trustcacerts -file EV_Root.cer
    keytool -import -alias EV_intermediate -keystore online.key -trustcacerts -file EV_intermediate.cer
    keytool -import -alias tomcat -keystore tomcat.key -trustcacerts -file tomcat.cer

Some references to retrieve private key from the key store that you generate.

June 28, 2010

How to Purge Emails at Linux Server using Command

Filed under: Linux, Server — Tags: , — vicker313 @ 12:53 pm

All the mails are stored in files at /var/mail, where each user will have their owned individual file. For example user James’ email will be stored at /var/mail/james. To purge all emails of a user, simply clear the content of the file using the following command:

cat /dev/null > /var/mail/james

Do not remove the file, or else the user will not able to receive email anymore. However by any change the file is removed, simple recreate back the file:

cat /dev/null > /var/mail/james

chown james:mail /var/mail/james

December 1, 2009

Tape Drive Hardware Compression

Filed under: Server — Tags: , , — vicker313 @ 8:00 am

Tape drive normally come with hardware compression feature. For example an LTO3 tape can store 400GB data with the hardware compression feature disabled, and able to store 800GB data with hardware compression feature enabled. Hardware compression is done at the tape drive, instead of using TAR or ZIP command.

By default, the hardware compression is enabled. To disable it, you can issue command below:

mt -f /dev/st0 compress 0

To enable back the compression feature:

mt -f /dev/st0 compress 1

To disable the default option of hardware compression:

mt -f /dev/st0 defcompression -1

To enable back the default option:

mt -f /dev/st0 defcompression 1

Transfer rate is much higher with hardware compression enabled.

November 14, 2009

Ultrium Tape Drive Performance Issue

Filed under: Server — Tags: , , , , — vicker313 @ 8:00 am

Recently I have setup a server to backup some data using Ultrium Tape Drive (Ultrium 960). The cartridge that I used was LTO3, able to store 800GB compressed data and 400GB uncompressed data. According to the specification, Ultrium Tape Drive was able to write  160MB data to tape in one second.

I installed a SCSI card to the server (PCI Express slot) and connected the tape drive to the server using a SCSI cable. First attempt was disappointed, the server cannot even detect the tape drive. Originally the server was Fedora Core 6, so I reinstalled it with Red Hat Enterprise 5.3 and OK, server was able to detect the tape drive. Now I used a simple TAR command to backup the data:

tar cvf /dev/st0 /backup

However the writing speed is very slow (around 30MB/s), few times slower than what the specification mentioned. First I suspected the bottle net might be the PCI Express, but no since the transfer rate was more than 160MB according to Google. Than I tested out the transfer rate of the SATA hard disk and it was the bottle neck. I used command below to benchmark the transfer rate of the hard disk:

dd if=/dev/zero of=test.bin bs=1M count=1000

The command basically will write 1GB of dummy data to your hard disk, and it will summarize the time and transfer rate after it finished (you can remove the dummy data afterward). It turned out the transfer rate was way to slow for a SATA hard disk (it should be around 160MB/s, but it turned out to be 30MB/s). After some digging, I found out that the server is using RAID 5, which potentially will result a performance bottle neck. Once again, I reinstalled the server with RAID 0+1.

Now I ran again command above and the result was positive, around 350MB/s. However I tried out the TAR command to backup data to the Ultrium Tape Drive, it was still slow, around 40MB/s. Lastly I tried to use a different block size in the TAR command:

tar cvfb /dev/st0 128 /backup

Option b in the TAR command referred to block factor, which 1 block factor equal to 512 bytes. Since I am using 128 block factor, it will result block size of 64KB. The default block factor is 20, which the block size will be 10KB. At last the transfer rate seemed great, around 100MB/s. While reading from tape was around 150MB/s.

June 5, 2009

Send mail using telnet

Filed under: Linux, Server, Windows — Tags: , — vicker313 @ 8:20 am

Some SMTP server allow you to send anonymous email (or even fake email), by using telnet. Telnet is available in both Windows and Linux.

  1. In your command prompt or terminal, issue following command:
    telnet smtp_server port
    smtp_server is either IP address or URL of the server, while port is the SMTP port of the server. The port normally is 25, but the server admin can change it to other number. Following is a example,
    telnet 25
  2. After login (if success), it will show a 220 something message without any prompt sign. Just type the following command and enter:
    helo domain_name
    domain_name is the host name of the server.
  3. Type in following command to set sender’s email address (any address, exists or not exists).
    mail from: sender_email
  4. Type in following command to set recipient’s email address.
    rcpt to: recipient_email
  5. Type in following command to trigger the starting of a message. This means you can start typing your message after this command.
  6. When the message is finished, type . (single dot) to end the message and email will be sent out.
  7. Type quit to logoff.

Aware that any typing error (and backspace for correction) might result a command syntax error.

Create a free website or blog at