Find the answer to your Linux question:
Results 1 to 6 of 6
Hi , just wondering , ive searched around some now, Im trying to make a bash script that restarts ./ventrilo_srv every 24 hours, any good idea of how to ? ...
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    8

    Bash - Auto restarter for Ventrilo every 24 hours.

    Hi , just wondering , ive searched around some now,

    Im trying to make a bash script that restarts ./ventrilo_srv every 24 hours,
    any good idea of how to ?

    Its going to restart every day at 06:00 ^^

    I know that this is very basic but ive just started php + mysql so i have to ask for this script Thanks in advance!

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Posts
    8
    Hi again, i forgot to tell you that im using SCREEN.

    So is there a script that can restart my VT server every 24 hours?
    automaticly..

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    8
    So anyone who know some basic bash scripting ?

    If linux had GOTO i would have done it like this..



    :startserver
    echo "Starter Ventrilo server"
    screen -A -m -d -S Ventrilo ./ventrilo_srv
    #example for how long to wait until to goto the shutdown step.
    sleep 10


    :startshutdown
    screen -r Ventrilo
    quit
    goto startserver

  4. #4
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    You should be using cron to do this.

  5. #5
    Just Joined! fatalexception's Avatar
    Join Date
    Feb 2007
    Posts
    34
    Quote Originally Posted by likwid
    You should be using cron to do this.
    Yes. Add a cron job which restarts it every day at 6:00. That's actually what cron is for.
    Quote Originally Posted by peec
    So anyone who know some basic bash scripting ?

    If linux had GOTO i would have done it like this..



    :startserver
    echo "Starter Ventrilo server"
    screen -A -m -d -S Ventrilo ./ventrilo_srv
    #example for how long to wait until to goto the shutdown step.
    sleep 10


    :startshutdown
    screen -r Ventrilo
    quit
    goto startserver
    Gotos are generally considered evil, and I've never come across an instance where they were necessary. Here's a workaround:
    Code:
    while : ; do
        echo "Starter Ventrilo server"
        screen -A -m -d -S Ventrilo ./ventrilo_srv
        #example for how long to wait until to goto the shutdown step.
        sleep 10
    
        screen -r Ventrilo
        quit
    done
    Keep in mind the only thing I've changed is the labels and the gotos. It's now an infinity loop via 'while'.

  6. #6
    Just Joined!
    Join Date
    Mar 2007
    Posts
    8
    Why not just a single executable file, restart_vento.sh
    Code:
    #!/bin/sh
    
    # Stop vento?
    echo "Stoping Ventrilo server"
    screen -r Ventrilo
    
    # Wait a while until we start it again
    echo "Waiting a while..."
    sleep 10
    
    # Start vento
    echo "Starting Ventrilo server"
    # Assuming "screen" follows the general rules for return values of int main(...)
    # the echo will only run when vetrilo is successfully started.
    screen -A -m -d -S Ventrilo ./ventrilo_srv && echo "Ventrilo server started successfully."
    Then in your crontabs, run restart_vento.sh every day at 6am

Posting Permissions

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