Search This Blog

Thursday, September 13, 2012

Windows Batch Script to Start, Stop and Restart a JAR file or JAVA Process


Windows Batch Script to Start, Stop and Restart a JAR file



To Start a JAR file using a batch script: 

echo Starting Your_JAR_File_Name!

start "
Your_JAR_File_Name" java -jar PATH_TO_Your_JAR_File_Name.jar


To Stop a running JAR file process using a batch script: 

echo Stopping Your_JAR_File_Name!

TASKKILL /f /FI "Windowtitle eq Your_JAR_File_Name"

Pause


To Restart a JAR file process using a batch script: 

@echo off
echo You are about to restart
Your_JAR_File_Name!

Pause

echo Stopping
Your_JAR_File_Name!

TASKKILL /f /FI "Windowtitle eq
Your_JAR_File_Name"

Pause

echo Starting
Your_JAR_File_Name!

start "
Your_JAR_File_Name" java -jar PATH_TO_Your_JAR_File_Name.jar

Tuesday, September 11, 2012

Configure NTP to synchronize the system clock in CENTOS/RHEL/FEDORA




CENTOS/RHEL/FEDORA: Configure NTP to synchronize the system clock


/* First install NTP on your system */
# yum install ntp

/* Now turn on NTP service */
# chkconfig ntpd on

/* synchronize your system clock with in.pool.ntp.org server */
# ntpdate  in.pool.ntp.org       //NTP server for India

/* Now start the NTP  Service*/
# /etc/init.d/ntpd start

/* Setting up a cronjob to sync automatically with NTP server every hour */
# crontab –e    // This will open a crontab file

/* Write the following line in the crontab file */
0 */1 * * * ntpdate  in.pool.ntp.org

/* Now save and close crontab file */



Saturday, September 8, 2012

How to access MySQL Server from outside




MySQL Server Remote Access

For accessing MySQL Server remotely from external network you to do port forwarding of SSH port 22 i.e. default port for SSH.

Step1: Edit /etc/my.cnf  
            # vi /etc/my.cnf
OR
# vi /opt/lamp/lamp/etc/my.cnf 
            Now locate file that read as :
            [mysqld]
            Make sure line skip-networking is commented and add the following line.
            bind-address= your-MySQlServer-IP (i.e. your system’s IP )

Step2: Save and close my.cnf file and restart mysql services.
            #service mysqld restart
OR
#/opt/lamp/lamp restart

Step3: Grant access to remote IP address:
            # mysql –u root –p “password for mysql”
            mysql> GRANT ALL ON *.* TO root@’Your network public IP’ IDENTIFIED BY  ‘PASSWORD’;        

Note: In the above mysql query “*.*’”, first * is indicates all databases and second * indicates all tables. So, if you want give access to a particular database all tables then write this query.
mysql> GRANT ALL ON <Database 1>.* TO root@’Your network public IP’ IDENTIFIED BY  ‘PASSWORD’;
Similarly for giving access to a particular table write the below query.
mysql> GRANT ALL ON <Database 1>.<table1> TO root@’Your network public IP’ IDENTIFIED BY  ‘PASSWORD’; 
mysql> exit

From your remote system or your desktop type the following command:

$ mysql -u root –h 10.10.10.1 –p

Where,
§  -u is MySQL username
§  -h IP or hostname is MySQL server IP address or hostname
§  -p : Prompt for password

OR

  You can use SQLYog software to connect from remote location.





How to change default MySQL port in linux




How To Change Mysql Port In Linux

Open and Edit /etc/my.cnf  OR  /opt/lamp/lamp/etc/my.cnf  using your favourite editor.

# vi /etc/my.cnf
OR
# vi /opt/lamp/lamp/etc/my.cnf 

Now find the line Port=3306 (default MySQL port) and change it to :
Port= new port no.   // make sure this port is not used for other     services. (/etc/services)

The below is my system’s my.cnf  file:
[mysqld]
user       = root
port       = 3307
socket     = /opt/lampp/var/mysql/mysql.sock
skip-external-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M


Now save and close my.cnf file and restart MySQL services:
#service mysqld restart
OR
#/opt/lamp/lamp restart


How To Reset A Root Password



HOW TO RESET A ROOT PASSWORD


If you forget or lose your system’s root password, then do the following to reset it.

Entering recovery mode

While is system is starting up, hold down the ctrl key to see the boot loader menu. After you see the menu do the following:
 Ø  Use the arrow keys to select the boot entry you want to modify.
 Ø  Press ‘e’ to edit the menu.
 Ø  Use the arrow keys to go to kernel line.
 Ø  Press ‘a’ or ‘e’ to append this entry.
 Ø  At the end of the line add word ‘single’ or the number ‘1’.
 Ø  Press Enter to accept the changes.
 Ø  Press ‘b’ to boot this kernel.
Now you will be seeing a root prompt.
Now you can change your system’s root password.  As root, changing password doesn’t ask for your old password.
Run this command:
 root@localhost# passwd


Resetting password when boot loader is password protected

 Ø  Boot form the installed OS CD/DVD.
 Ø  Select “Rescue Installed System”
 Ø  Answer the prompt for language & keyboard.
 Ø  Let the rescue mode mount your file systems in the read/write mode.
 Ø  Press Enter to get the shell prompt.
 Ø  At the prompt, enter the following commands.
# chroot /mnt/sysimage
# passwd
# exit
# exit