Combining various command options can lead to hideously complex commands. If you are loath to type such long-winded commands on a regular basis, Unix and Linux offers the shell script option, which merits a brief detour. Here is you can find out simple practical approach of shell script. You can readily see ps command; say so that ps perform a complex command with less typing effect.
Using ps command you can get result of Oracle processes with instance name.
ps –ef | grep smon| grep –v grep
The output comes with all running smon processes of Oracle instances. If you create file with name “trap_smon” or something else and write down these all commands in same file. It is called as shell script because it contains all shell commands.
vi trap_smon
ps –ef|grep smon| grep –v grep
After saving above trap_smon file, you can execute using command sh trap_smon and get output of same at any time. You can schedule it too using crontab utility of Unix and Linux. If you don’t want to execute using “sh trap_smon” then you need to make it executable. After changing permission of shell script, you can able to make it executable as following.
chmod +x trap_smon
trap_smon
The u+x option in chmod gives you alone permission to execute, as the owner. If you want to grant all users permission to use trap_smon, you would vary the chmod option as follows
chmod a+x trap_smon
Or
chmod +x trap_smon
If you want to provide permission to your group only then you can use g+x with change permission command as following.
chmod g+x trap_smon
After using chmod, you should run ls –l trap_smon to check that it has correct x fields for your purposes.
Shell scripts are available for all shells like Bourne, Korne, C shells, although the syntax and available features are different. Peculiar to the C shell, though, is another keystroke-saving ploy called the alias command.
As Database DBA you need to understand how to create simple shell script for maintaining your daily tasks. If you need more details of shell scripting then you can find out from some excellent Oracle DBA blog or some good database support sites.
Using ps command you can get result of Oracle processes with instance name.
ps –ef | grep smon| grep –v grep
The output comes with all running smon processes of Oracle instances. If you create file with name “trap_smon” or something else and write down these all commands in same file. It is called as shell script because it contains all shell commands.
vi trap_smon
ps –ef|grep smon| grep –v grep
After saving above trap_smon file, you can execute using command sh trap_smon and get output of same at any time. You can schedule it too using crontab utility of Unix and Linux. If you don’t want to execute using “sh trap_smon” then you need to make it executable. After changing permission of shell script, you can able to make it executable as following.
chmod +x trap_smon
trap_smon
The u+x option in chmod gives you alone permission to execute, as the owner. If you want to grant all users permission to use trap_smon, you would vary the chmod option as follows
chmod a+x trap_smon
Or
chmod +x trap_smon
If you want to provide permission to your group only then you can use g+x with change permission command as following.
chmod g+x trap_smon
After using chmod, you should run ls –l trap_smon to check that it has correct x fields for your purposes.
Shell scripts are available for all shells like Bourne, Korne, C shells, although the syntax and available features are different. Peculiar to the C shell, though, is another keystroke-saving ploy called the alias command.
As Database DBA you need to understand how to create simple shell script for maintaining your daily tasks. If you need more details of shell scripting then you can find out from some excellent Oracle DBA blog or some good database support sites.