Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I wish to enable my shell script to automatically run whenever my system starts up. What should be the steps, Plz reply!!!!! Thanks...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3

    automating a shell script

    Hi,

    I wish to enable my shell script to automatically run whenever my system starts up.
    What should be the steps, Plz reply!!!!!

    Thanks

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Place the command in your .bashrc file.

    Regards

  3. #3
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Franklin52, that won't quite do it. That will only execute the script when the user starts a new interactive bash session (other than when he logs in), or when the user runs ~/.bashrc explicitly. Of course, the whole concept of "~" (the username) doesn't make sense when the system is still coming up and nobody has logged in yet.

    Babul Rk, the answer depends on which distribution of Linux you're running, and whether you want to
    1. make this script part of the boot process itself (that is, run for a short while to set things up and then exit); or
    2. run interactively through the screen and keyboard.


    So we need two things: your distribution, and whether you want keyboard interaction.

  4. #4
    Just Joined!
    Join Date
    Oct 2007
    Posts
    2
    hi,

    Place your script /etc/rc.local

  5. #5
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Place your script /etc/rc.local
    That may work in some distributions, but it won't work in (for example) Slackware. In Slackware, you want to name your script in the script /etc/rc.d/rc.local

    That's why I asked Babul Rk which distribution he was running.

  6. #6
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3
    I am running both RH 4 and FC 4, and i donot want a keyboard interaction.
    I appreciate for your reply and looking forward for more.
    Thanks

  7. #7
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    It should work the same on both RH and FC.

    I don't know anything about those systems, but I googled. If you have on your system a file called /etc/rc.d/rc.local, place the full pathname of your script in there.

    Please note that the system won't finish booting until after your script has finished running. If it's something that is to be run forever, even after the system has come up all the way, place an ampersand & at the end of the line that names your script. That way, the system won't wait for your script to complete (or even run very long) before continuing the booting sequence.

    I see web-rumors that /etc/rc.local is a symbolic link to /etc/rc.d/rc.local. I can't verify this; you'll have to look for yourself.

    But the name of the file to contain your script name, /etc/rc.d/rc.local, is just a guess. Is there any Red Hat/Fedora expert out there?

  8. #8
    Just Joined!
    Join Date
    Oct 2007
    Posts
    3
    Well thats hard to find but let me check and get back.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...