Thursday, August 30, 2012

Scheduling a task using 'crontab'

Suppose you want to schedule a task in Linux and you want it to run periodically, then 'crontab' command is what you are looking for. I've just learned this, so I still don't know much details about it, but following is what I've learnt.

Syntax:

To create a 'crontab' entry,

                      #crontab -e 

To get a list of crontab entries you have,

                      #crontab -l

The way that you should edit the crontab file, (vi editor will be used)

                       'min' 'hr' 'day' 'mon' 'day-of-week' <command>

min - minute of the hour.(ex: 15)
hr - hour of the day(ex: 3)
day - day of the month(ex: 29)
mon - month of the year(ex: 5)
day-of-week - As name implies.(ex: 0)   0 is sunday.
command - This is the command you want to execute.


Example:

Following will write "Crontab is working" to 'abc.log' file in /home/pradeepa directory. (use your username instead of pradeepa) 

                * * * * * echo "Crontab is working" >> /home/pradeepa/abc.log

And the star mark is used to tell "every".

There is a great article on crontab in wikipedia,


This is just an introduction to 'crontab', what you can do from this is up-to your innovative mind.

Cheers.

Saturday, August 25, 2012

Installing java on rhel6

Recently I was trying to install java on my rhel6 o/s. But there were so many links in the internet which i couldn't understand. But finally i found a great wiki site which helped me accomplishing this task.

http://wiki.rosalab.ru/en/index.php/Howto_install_proprietary_Java_from_Oracle#JDK_7u6_64bit

Going through this will solve all the problems.
But 'javaws' is not working for me.

:)

Thursday, August 16, 2012

Adding a static route in RedHat

This post gives a step by step guide on how to setup a static route. This post will not have any in-depth details, so it is just for newbies just like myself.

First step is going to the root

#su -l

Then you have to go to the following directory which contains details about interfaces as well as about the routes,

#cd /etc/sysconfig/network-scripts/

You can use the 'Tab' key to autofill the commands in linux cli as well as the directory names :) which often makes your life easier.

Now since we are in the correct location what we have to do is adding the route to a special file with the name 'ifcnfg-route'. I will use the 'vi editor' for this task.

#vi route-eth0

This file can be blank if your linux os does not have any routing configured.

Now you need to know basic commands in 'vi editor' in order to edit this document and save it. When I first use the 'vi editor' it was pretty confusing, but going googling 'vi commands' gave me enough insight about this editor. After getting to know all the commands it will be a pretty easy editor to use. :)

So there we just need to put a small entry,

<destination network> via  <gateway to be used>

example:

                     10.1.60.0 via 10.1.1.254

But make sure that the gateway ip-address is available in your networks.

Then save the editor and exit.

Make sure you restart your interfaces after doing any modification.

 #/etc/init.d/network restart

Finally, check your configuration by typing

#route -n

If your entry is displayed in the output, then you did it correctly :)

Thank you.
Pradeepa






Tuesday, August 14, 2012

Configuring IP on RedHat

This post will give you step by step guide to configure a static ip address to an interface in the RedHat operating system. Since I am also a newbie this post will not be that hard to understand.

First go to the root, 

#su -l

Then open the file which contains details about the interface.

#vi /etc/sysconfig/network-scripts/ifcfg-eth0

This will open that file in the vi editor. Now all you have to do is adding some entries to the file.

Following web site will contain details about the vi editor,

                  http://www.cs.rit.edu/~cslab/vi.html

Entries that should be added,

DEVICE="eth0"
HWADDR="08:00:27:4F:CF:22"
NM_CONTROLLED = "no"
ONBOOT="yes"
IPADDR=10.1.1.1
NETMASK=255.255.255.0

Above entry is to add ip address 10.1.1.1 with a mask of 24 to the ethernet0 interface.

After that make sure you save the vi file and exit.

Finally restart the interfaces,

#/etc/inti.d/networks restart

To verify the configuration you can simply type,

#ifconfig 

Then check under the eth0 interface and verify all the configuration.

Thank you,
Pradeepa.