Start Up Scripts

Discussion in 'Linux & BSD' started by sean.ferguson, Sep 22, 2007.

  1. sean.ferguson

    sean.ferguson Moderator Folding Team

    Messages:
    1,693
    Location:
    Fife; Scotland
    How can I write a script that will run a program ( ~/folding/FAH502 ) everytime the server boots up.

    I know that cronjobs can run things at a certain time, but my server isnt important enough to warrant purchasing a UPS so when we have a powercut i need to run around and restart all my running apps. Is there a way I can put these in a script that can be run on system boot?

    Ideally I would like a screen session to be opened first, and then the program in question ran. That way I can manage the progress etc remotely without needing local access to the machine.
     
    Last edited: Sep 22, 2007
  2. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    Depending on the linux flavour of the week, create a script in either:

    /etc/init.d
    /etc/rc.d
    /etc/runlevel.d

    Or if it is FreeBSD:

    /usr/local/etc/rc.d

    And just prepend the command to be run by a "screen" and it will be executed in a screen.
     
    sean.ferguson likes this.
  3. sean.ferguson

    sean.ferguson Moderator Folding Team

    Messages:
    1,693
    Location:
    Fife; Scotland
    Thanks X, the flavour is Slackware 10.2 and I have just been speaking to someone on YIM who has said that there is a crontab special flag "@reboot" - I wasn't aware of such flags.

    So in that case I have just added the following line to my users crontab

    Code:
    @reboot screen -d -m ~/folding/FAH504-Linux.exe
    I'l have a look at those files also though, just to make myself familiar