simple shutdown script

Discussion in 'Programming/Scripts' started by staticanime, Dec 26, 2008.

  1. staticanime

    staticanime New Member

    Hey, I'm trying to make a script to be run by VirtualMin to stop my xbtt torrent tracker when the server is shutdown/restarted.

    I have a script called stop-xbtt.sh and in it I have
    Code:
    #!/bin/sh
    cd /home/xbtt/Tracker/
    kill 'cat xbt_tracker.pid'
    
    now, I can't get the kill 'cat xbt_tracker.pid' to work. All I wanted it to do is read the PID number in the xbt_tracker.pid (which works with cat) and pass it onto kill :(

    PS. Server is Ubuntu 8.04
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Try
    Code:
    kill ´cat xbt_tracker.pid´
    instead of
    Code:
    kill 'cat xbt_tracker.pid'
     
  3. staticanime

    staticanime New Member

    Yep, that worked like a charm, thanks Falko
     
  4. stutch

    stutch New Member

    How would I set this up if I wanted it to execute before the server is brought down automatically?
     
  5. sjau

    sjau Local Meanie Moderator

    why not write a real initrd script and then add it to the default runlevels?
     
  6. ebal

    ebal New Member

    kill sends TERM signal so there is a possibility not to kill your process.

    I use pkill command without knowing the PID of the process and after a sleep i use pkill -9 just to be sure.

    something like this:

    Code:
    pkill apache
    sleep 3
    pkill -9 apache
    
     
  7. sjau

    sjau Local Meanie Moderator

Share This Page