Author Topic: How do I create a script that will restart another script after so many minutes?  (Read 9059 times)

0 Members and 3 Guests are viewing this topic.

Offline helen

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
  • KISSY KISSY KISSY LICKY LICKY LICKY
    • View Profile
Okay I have OmnomIRC running in my channels which keeps closing now apparently it needs an auto restart script according to Nathem. How do I create one? I tried Googling but had no success what so ever. Is this in the wrong place or is there a better place for it?
« Last Edit: February 08, 2012, 05:16:51 pm by helen »

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
You could just do something like this:
Code: [Select]
p="process name"
while true; do
/path/to/process/to/run;
while [ "$(ps -C $p | grep $p)" != "" ]; do
sleep 3;
done;
done;
I haven't tested it but with some tweaking I'm pretty sure it should do what you want.
/e

Offline helen

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
  • KISSY KISSY KISSY LICKY LICKY LICKY
    • View Profile
You could just do something like this:
Code: [Select]
p="process name"
while true; do
/path/to/process/to/run;
while [ "$(ps -C $p | grep $p)" != "" ]; do
sleep 3;
done;
done;
I haven't tested it but with some tweaking I'm pretty sure it should do what you want.

Okay I think it's working! :3 Okay sorry it's NOT working. :(
« Last Edit: February 09, 2012, 01:29:10 pm by helen »

Offline helen

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
  • KISSY KISSY KISSY LICKY LICKY LICKY
    • View Profile
You could just do something like this:
Code: [Select]
p="process name"
while true; do
/path/to/process/to/run;
while [ "$(ps -C $p | grep $p)" != "" ]; do
sleep 3;
done;
done;
I haven't tested it but with some tweaking I'm pretty sure it should do what you want.

Okay I think it's working! :3 Okay sorry it's NOT working. :( I can't find what the process would be.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Well if I remember correctly it would probably be the name of the script/binary you are running. You could try changing it to ps -A instead, it's just less precise.
/e

Offline helen

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
  • KISSY KISSY KISSY LICKY LICKY LICKY
    • View Profile
Well if I remember correctly it would probably be the name of the script/binary you are running. You could try changing it to ps -A instead, it's just less precise.
I've tried looking through ps -A in the past only to find that my bots process names are "PHP". Any way of changing a process name for a bot?
« Last Edit: February 09, 2012, 02:09:46 pm by helen »

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Oh it's a php bot? How are you running it?
/e

Offline helen

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
  • KISSY KISSY KISSY LICKY LICKY LICKY
    • View Profile
Oh it's a php bot? How are you running it?
php OmnomIRC.php

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Netham45 appears to have the same problems for his OmnomIRC it seems. I wonder if your script could actually fix our split channel problems Eeems? (so we don't have to rely on AaronBot or Jimbauwen every few week or so)

Offline helen

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 17
  • Rating: +1/-0
  • KISSY KISSY KISSY LICKY LICKY LICKY
    • View Profile
Netham45 appears to have the same problems for his OmnomIRC it seems. I wonder if your script could actually fix our split channel problems Eeems? (so we don't have to rely on AaronBot or Jimbauwen every few week or so)
You seriously rely on AaronBot? :o That thing is buggy! I used it as a relay and it kept getting mixed up and ended up relaying other peoples channels to mine.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
You could modify the php script to write its pid to a file each startup.
« Last Edit: February 09, 2012, 02:28:48 pm by Juju »

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Netham45 appears to have the same problems for his OmnomIRC it seems. I wonder if your script could actually fix our split channel problems Eeems? (so we don't have to rely on AaronBot or Jimbauwen every few week or so)
You seriously rely on AaronBot? :o That thing is buggy! I used it as a relay and it kept getting mixed up and ended up relaying other peoples channels to mine.
It didn't seem too bad last night, although when Alberthrocks modified it at one point it started freaking out. We only rely on AaronBot when Jimbauwen is not online.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
You could do the pid thing. You could also run the script itself ( ./OmnomIRC.php ( make sure to add the right stuff to the start of it ( #!/usr/bin/php5 ) ) ) that way the process name will be the name of the script instead of php :)

EDIT: @ DJ: my script probably wont fix the issues where omnom stops relaying to one of the channels. That is a code issue I think. Unless he has multiple processes ( one per server he connects to ).
« Last Edit: February 09, 2012, 02:41:39 pm by Eeems »
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Ah ok I was wondering, in case he didn't try it.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
I think he already has an auto-restart script. I'm not sure though, we'd have to ask him.
Oh, and btw helen, this script will also start Omnom on its own if it isn't running. You can start it first or just my script, it doesn't really matter.
/e