Thursday, October 18, 2012

Multiple schedules in CRONTAB

CRONTAB can be used to schedule applications.

There are some situations, you have to run application for a few times for a day.

Following example, demonstrates the sample crontab to run two schedules.

0 10,18 * * * /home/sujith/apps/

Above crontab will run the schedule( twice a day. (10 AM & 18 PM)

JAVA relative path issue in CRONTAB

It can be occurred issues relative to files access when you have used relative path in JAVA application which are used by crontab in linux. crontab cannot be used in relative paths. One solution is to change JAVA application file access to FULL paths. Another solution is to create shell script as follows. Then, this script can be used by crontab without issues.

cd /home/sujith/app_location
/usr/jdk1.7.0_07/bin/java -jar -Xms512m -Xmx1024m app_name.jar

Tuesday, October 9, 2012

mysqldump Command Usage

It is used mysqldump command to get a backup of existing tables.

Simply, run the following command to get the backup.

mysqldump -usujith -psujith database_name table_name  > /home/sujith/backup.sql

NOTE :- This dump contains all the table structure and data in table.

Thursday, October 4, 2012

Random String (ID) generate in JAVA

java.util.UUID package contains random String generation feature.

Refer below code.

UUID uuid = UUID.randomUUID();

Generated Strings


Wednesday, October 3, 2012

MySQL outfile write permission

When unloading data from MySQL database, it is needed to given special WRITE permission for user to write files.

Refer below command.

SQL command for unload data

  • select * into outfile '/tmp/testfile.txt' fields terminated by '|' from recharge where req_date<'2012-10-03';

SQL command to grant write permission

  • GRANT FILE ON *.* TO 'sujith'@'localhost';
  • flush privileges;

Tuesday, October 2, 2012

MySQL grant permission

It is needed to grant permission in MySQL server for users of the database. Below MySQL commands can be used to grant permissions.

  1. grant all privileges on database.* to 'sujith'@'localhost';
  2. flush privileges;
Refer MySQL documentation for more details.

Monday, October 1, 2012

export EDITOR=vi

In some cases, it is not shown data in Linux terminal window. In that case, you can use "vi editor" to view hidden data.

Following command can be used to export data to vi editor.

export EDITOR=vi   

This is most commonly used for crontab edition.