Wednesday, September 23, 2020
    Home Technology A 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 so 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 -

    Ps –ef | grep smon| grep –v grep

    The output comes with all running smon processes of Oracle instances. If you create a file with 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 -

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

    Chmod +x 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


    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.

    - Advertisement -
    - Advertisment -

    Most Popular

    ORA-01194: file 1 needs more recovery to be consistent

    The blog post explains how to restore and recover database using until cancel with error ORA-01194

    How to enable Archivelog

    This blog post explains how to enable archive log mode in Oracle database for newest versions.

    Shared vs Static Library Performance

    The article explains the benefits of a shared library and static library usage in application building for improving application performance.

    Migration methods of Oracle Database

    Blog post explains which tricks and methods are simple to perform migration of small and large Oracle database

    Recent Comments