Welcome to the Part 2 of this series , We have discussed about grep,ls,awk,find in my last post
Basic Shell command to make ourselves comfortable at all times
In this post we are gonna see some crontab and vi editor options.
Basic Shell command to make ourselves comfortable at all times
In this post we are gonna see some crontab and vi editor options.
Crontab :
Crontab is a utility provided by linux to schedule jobs or scripts , Like if you want to run a job every morning 8:00 am , you can do this with the crontab utility
dbadm@linux122:~> crontab -l # DO NOT EDIT THIS FILE - edit the master and reinstall. # (/tmp/crontab.XXXX7mwgtU installed on Tue Nov 12 17:53:36 2013) # (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $) #### BACKUPS 01 01 * * * /home/DB_BKPS/scripts/sample1_backup.sh 01 02 * * * /home/DB_BKPS/scripts/sample2_backup.sh
Now we will see the 6 fields in cronjob that help us to schedule jobs
Field Description | Range |
---|---|
MINUTE | 0 - 59 |
HOUR | 0 - 23 |
Day in Month | 0 - 31 |
Month | 1 - 12 |
Day in Week | 0 - 6 |
Command | Script or command to be executed |
Let us see some examples
Ex 1 :
Now you want to schedule a script everyday at 01:10 am
01 10 * * * /home/DB_BKPS/scripts/sample1_backup.shSchedule for every 1 hour
00 */1 * * * /home/DB_BKPS/scripts/sample1_backup.shScheduled everyday at 01:10am from MON-WED
01 10 * * 1-3 /home/DB_BKPS/scripts/sample1_backup.sh
Vi editor :
Vi is a powerful editor , Here i provide you some basic options you need to be good at
Basic modes of vi editor
- Command mode : ESC
- Insert mode : i
- Append mode : a
Note : Pressing ESC in any mode bring you back to command mode
The moment you open the vi editor it will be in command mode
Press 'i' to enter into insert mode - starts inserting from right from the cursor position
Press 'a' to enter into append mode - starts inserting from the next word of the cursor position
Press 'i' to enter into insert mode - starts inserting from right from the cursor position
Press 'a' to enter into append mode - starts inserting from the next word of the cursor position
Basic Search text option
- Search for text (top to bottom): /
- Search for text (bottom to top): ?
Start search for text with wildcard '/'
For Ex :
/IBMDB2 - searches for IBMDB2 from top to bottom - press 'n' to find the next occurrence of the word towards bottom
?IBMDB2 - searches for IBMDB2 from bottom to top - press 'n' to find the next occurrence of the word towards top
For Ex :
/IBMDB2 - searches for IBMDB2 from top to bottom - press 'n' to find the next occurrence of the word towards bottom
?IBMDB2 - searches for IBMDB2 from bottom to top - press 'n' to find the next occurrence of the word towards top
Mode : Command
Basic Search And Replace
Say you have a large file and want to replace the word Obama with Barrack, this is how you do it
Say you have a large file and want to replace the word Obama with Barrack, this is how you do it
:%s/Obama/Barrack/gNow all the words 'Obama' in that file will be replaced by 'Barrack'
Mode : Command
Some other miscellaneous vi editor stuff
dd - deletes line
xx - deletes word
:$ - move to the end of the file
:1 - move to the starting of the file
:100 - move to the 100th line of the file
xx - deletes word
:$ - move to the end of the file
:1 - move to the starting of the file
:100 - move to the 100th line of the file
So , these are some basic stuff of the Linux world you need to have an idea about
Have a nice Day
No comments:
Post a Comment