#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Post How to make script commands


    hi guys ,

    i want make script for this commands (df -k , ps -ef|grep tomcat ,top )
    for daily check to my system .. i try it but i couldn't and i am fresher in linux os so i need help in this task
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    Open a text editor (gedit / vi / vim / kate - whatever takes your fancy).

    As the first line, type
    #!/bin/bash

    As the second line, type a command line you would like to script, say
    df -k

    So you should have two lines like this
    #!/bin/bash
    df -k

    Save the file as say myscript.sh

    Back at your command prompt, type
    chmod u+x myscript.sh

    Now type at your command prompt
    ./myscript.sh
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo