remote dba support
More
    HomeTechnologyA Simple Shell Script Example

    A Simple Shell Script Example

    A Simple Shell Script Example

    shell script exampleCombining 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 offer the shell script option, which merits a brief detour. Here is you can find out the simple practical approach of shell script. You can readily see ps command; say that ps perform a complex command with less typing effect.

    Using ps command, you can get a result of Oracle processes with the instance name.

    - Advertisement -
    dbametrix

    Ps –ef | grep smon| grep –v grep

    The output comes with all running smon processes of Oracle instances. If you create a file with the name “trap_smon” or something else and write down these all commands in the same file. It is called a shell script because it contains all shell commands.

    Vi trap_smon

    Ps –ef|grep smon| grep –v grep

    - Advertisement -
    dbametrix

    After saving the above trap_smon file, you can execute using the command sh trap_smon and get the output of the 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 the permission of the shell script, you can make it executable as follows.

    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 follows.

    Chmod g+x trap_smon

    After using chmod, you should run ls –l trap_smon to check that it has the correct x fields for your purposes.

    Shell scripts are available for all shells like Bourne, Korn, 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.

    When you want to make a strong Oracle DBA career then you should be aware of database services and other database technology. Without having knowledge of Oracle internals, Oracle performance tuning, and skill of Oracle database troubleshooting you can’t be an Oracle DBA expert.

    This expert DBA Team club blog always provides you latest technology news and database news to keep yourself up to date. You should need to be aware of Cloud database technology like DBaaS. All Oracle DBA tips are available in a single unique resource at our orageek. Meanwhile, we are also providing some sql tutorials for Oracle DBA. This is the part of Dbametrix Group and you would enjoy more advanced topics from our partner resource.

    - Advertisement -
    dbametrix
    - Advertisment -
    remote dba services

    Most Popular