Sunday 15 April 2012

rpm,Task Automation and Scheduling In Linux

RPM (RedHat Package Manager):


RPM package contain the file and directories associated with specific application and program.
RPM namegenerally includes version, release and architecture for which it was build.
Like
Zip-2.3-8.i386.rpm

To install RPM:
#rpm –i rpm_name

To Remove RPM
#rpm –e rpm_name

In order to remove those package which has dependency
#rpm –e rpm_name –nodeps

Switches used with RPM
-i or --install
-e or --erase
-U or--Upgrade
-F or --Freshen
we can install rpm by using
#rpm –ivh rpm_name
-I          :           Install
-v         :           Verbose
-h         :           Human view (Hash Sign)

To Upgrade RPM:
#rpm –U rpm_name

To repair any corrupted rpm package
#rpm –F rpm_name

To make any rpm query
#rpm –q rpm_name

To check all rpm of related pacakes
#rpm –qa |grep rpm_name

To check particular file associated with which rpm
# rpm –qf /etc/passwd
passwd file is associated with setup-2.5 rpm

To check the rpm containing which file
#rpm –ql rpm_name
this command will list all the file associated with particular rpm.
To get the information about the particular rpm.
#rpm –qi rpm_name

To Install any rpm forely
#rpm –ivh rpm_name –force

Installing dependent packages:
Suppose we have 4 rpm’s r1,r2,r3 and r4 , we need to install r4 but r4 depends on remaining rpm’s then we use this command.

To check any rpm’s query
#rpm –qa “sendmail*”

To check rpm’s of related service
#rpm –qa |grep bind

 Task Automation and Task Scheduling:-


It is used to perform the task at particular time
Two command are used
a.      at
b.      crontab
syntax:
#at time
at>command I
at>command II
ctrl+D

Example:
#at 10:30
at>eject
at>eject –t
ctrl+D

Option used
#at now
#at now+5 minutes
#at now+5 hours
#at now+5 days
#at tomorrow
#at 10:30 july 16 2006
we can also restrict the user not to use the ‘at’ command. Restriction will be provided by root login with administrator.
#vi /etc/at.deny
inside this file we have to just mentioned the name of the user in order to restrict him not to use ‘at’ command.
Just save and exit form the file
By default all users are allowed to use ‘at’ command. ‘at.deny’ is default in system. We can also create a file ‘at.allow’ file. Once we create this file, now by default all users will be restricted to use ‘at’ command and only that user which have entry on ‘at.allow’ will allow to use the ‘at’ command.
Another method is to make an entry inside the ‘crontab’ file. Entry will be done by the root. Difference between these two method is crontab is used to perform the same task many times whereas job through ‘at’ command will be removed after the task has been performed.
Syntax: ( By root login)
#crontab –e
six field are listed
1                        2                        3                     4                      5                      6
minute                        hour                day of              Month             day of              command
                                                month                                     Week
Example:
35                    10                   31                     05                     3                   eject
36                    10                   31                     05                     3                   eject –t

Minute                        :           0-59
Hours              :           0-23
Day of Month :           1-31
Month             :           1-12
Day of Week   :           0-7
0 and 7 are Sunday

#service crond restart

#whereis eject
this command display the path of the command. It is better to use the full path of the command inside crontab instead of just the name of the command.
We can also make the entry as
35                    10                    *                       *                       *                       eject
36                    10                    *                       *                       *                       eject –t

In this case. These two jobs will be performed at 10:35 in every month.
Some command which are executed with ‘at’ or ‘crontab’ send their output to the user mail box. These command are executed on background and their output is transferred to the particular user’s mail box. In order to see the output of the command we use.
#mutt
This command will open the mailbox from where we check the output
Some of the switched used with the ‘crontab’
#crontab –l
List out all the job scheduled in crontab.

#crontab –r
Can remove the job from the crontab.        
#atq : list the job number scheduled in at
#atrm jobno    : to remove any job

Thanks ,

No comments:

Post a Comment