Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, I'm looking to run a script at startup of a CentOS 64Bit VPS. I have the script pretty much written just don't know how to make it run. Any ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Location
    Scotland, UK.
    Posts
    5

    Run script at boot

    Hello,

    I'm looking to run a script at startup of a CentOS 64Bit VPS.

    I have the script pretty much written just don't know how to make it run.

    Any help will be appreciated!

    Thanks.

  2. #2
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    In general, you can put commands/scripts in /etc/rc.local to run at startup, or in some distros it's /etc/rc.d/rc.local.
    An introduction to services, runlevels, and rc.d scripts | Linux.com

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Location
    Scotland, UK.
    Posts
    5
    I went into /etc/rc.local and it seems that is the place to put it.

    So say my script is fixup.sh. Would I put;

    sh /etc/fixup.sh or just /etc/fixup.sh

    Also, to delete it when it's finished, would I just put rm /etc/fixup.sh the line below?

    Thanks.

  4. #4
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    Just /etc/fixup.sh, but your script should be flagged as executable first.
    Code:
    chmod +x /etc/fixup.sh
    You want to delete the script afterwards? Yeah, rm /etc/fixup.sh should work.

    By the way, odd location for the script.

  5. #5
    Just Joined!
    Join Date
    Jun 2010
    Location
    Scotland, UK.
    Posts
    5
    It's just a very basic script to make my life a bit easier for cPanel VPS servers. I've pasted the content below. Don't laugh , it's my first script. Any help on improving it will be appreciated!

    Code:
    #!/bin/bash
    cd
    echo "Updating the System"
    yum -y update
    echo "Updating cPanel/WHM"
    /scripts/upcp
    echo "Installing ConfigServer Security & Firewall"
    rm -fv csf.tgz
    wget ---csf.tgz
    tar -xzf csf.tgz
    cd csf
    sh install.sh
    cd
    rm -fv csf.tgz
    echo "Installing ConfigServer ModSecurity Control"
    rm -fv cmc.tgz
    wget ---csf.tgz
    tar -xzf cmc.tgz
    cd cmc
    sh install.sh
    cd
    rm -fv cmc.tgz
    echo "Installing ConfigServer Explorer"
    rm -fv cse.tgz
    wget ---cse.tgz
    tar -xzf cse.tgz
    cd cse
    sh install.sh
    cd
    rm -fv cse.tgz
    echo "Installing ConfigServer Mail Queues"
    rm -fv cmq.tgz
    wget ---cmq.tgz
    tar -xzf cmq.tgz
    cd cmq
    sh install.sh
    cd
    rm -fv cmq.tgz
    echo "Installing ConfigServer Mail Manage"
    rm -fv cmq.tgz
    wget ---cmm.tgz
    tar -xzf cmm.tgz
    cd cmm
    sh install.sh
    cd
    rm -fv cmm.tgz
    echo "Done!"
    I just need that to be run at boot up and then delete itself when finished.

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