# crontab & restart

Jasper Phillips (philljas@ENGR.ORST.EDU)
Tue, 29 Jul 1997 13:50:53 -0700

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    >
    > So, does anyone know how to get a cron job working to restart a moo
    > once a week? The restart.sh that comes with the code uses nohup, which
    > requires a terminal, so I can't call that. I tried just calling the
    > command-line startup but that didn't work either. I keep getting a
    > "must be called from a terminal" error.
    >
    >
    > Diana
    > aka Trouble @ DownMOO

    Well, the following perl script works for me. Checks to see if the MOO is
    up every half hour, and restarts it if it isn't. Strangely I've never
    run into your problem with nohup (my crontab happily runs restart,
    as you can see from this script...), perhaps you've some strange limitation
    on your system or your account thats getting in your way?

    Oh yah, the flags for ps on your machine could be different... I'm on
    Redhat.

    -Jasper

    #!/usr/bin/perl
    #
    # By: Jasper; July 11th, 1997
    #
    # This perl script is intended to be cronned to check to see if
    # a given MOO is running, and if it's not, to attempt to restart it.
    #
    # This file needs to be in the same directory as your moo.db, and executable.
    #
    # A line something like the following needs to be added with crontab -e
    # 0,30    *       *       *       *       cd <MOO_DIR> ; restart_cron.perl
    # This checks to see if the mud is up every half hour, assuming this script
    # is named restart_cron.perl.
    #
    # NOTE: Is this really worth anything? It'll only come up if rc.local
    # isn't set, or if the moo just crashes...
    #########################################################################

    $MOO = "pandemonium" ;                          # Your database prefix
    $MAIL_TO = "philljas\@engr.orst.edu" ;          # Who to mail

    unless ( `ps x` =~ /$MOO/ ) {
            `restart $MOO` ;

            if ( `ps x` =~ /$MOO/ ) {
                    `date | mail $MAIL_TO -s "$MOO crashed, then restarted"` ;
            }
            else {
                    `date | mail $MAIL_TO -s "$MOO crashed, failed to restart!"` ;
            }
    }

    --
                  /\  Jasper Phillips (Pit Fiend)  ______,....----,
    /VVVVVVVVVVVVVV|===================""""""""""""       ___,..-'
    `^^^^^^^^^^^^^^|======================----------""""""
                  \/  http://www.engr.orst.edu/~philljas/