Any way to run a script on server restart?

Discussion in 'Site & Server Administration' started by fri3ndly, Sep 27, 2010.

  1. #1
    Hello

    I have a VPS which is currently running a cron job every 12 hours. The cron job script sets a database entry when it first runs to true so that the script knows that if it is run again and this is set to true then it should exit the script (to prevent overlapping cron jobs). Once the script is finished it resets that database field back to false.

    The problem is that every now and then my server restarts (about 3AM in the morning) for no apparent reason and therefore the script is terminated without setting the field to false which results in my script never running any more.

    My question is whether there is a way to automatically run a php script on every system restart?

    Thanks
     
    fri3ndly, Sep 27, 2010 IP
  2. Alexctrls

    Alexctrls Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes there is a way but let me know which panel are u running

    there is option call start on boot
     
    Alexctrls, Sep 27, 2010 IP
  3. fri3ndly

    fri3ndly Active Member

    Messages:
    111
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for your reply.

    I am using Plesk 9.3
     
    Last edited: Sep 27, 2010
    fri3ndly, Sep 27, 2010 IP
  4. madaboutlinux

    madaboutlinux Member

    Messages:
    250
    Likes Received:
    7
    Best Answers:
    2
    Trophy Points:
    43
    #4
    You can specify the PHP script in the /etc/rc.local file to execute it during the server reboot. Edit the /etc/rc.local file and specify the php script as

     
    madaboutlinux, Sep 27, 2010 IP
  5. fri3ndly

    fri3ndly Active Member

    Messages:
    111
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Many thanks!!!
     
    fri3ndly, Sep 27, 2010 IP
  6. bigbody300

    bigbody300 Well-Known Member

    Messages:
    1,282
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    130
    #6
    you can code it to Restart on reboot - simple code actually.
     
    bigbody300, Sep 27, 2010 IP