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

0 Members and 1 Guest are viewing this topic.

#### helen

• LV1 Newcomer (Next: 20)
• Posts: 17
• Rating: +1/-0
• KISSY KISSY KISSY LICKY LICKY LICKY
##### How do I create a script that will restart another script after so many minutes?
« on: February 08, 2012, 05:10:20 pm »
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 »

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6250
• Rating: +318/-36
• little oof
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #1 on: February 08, 2012, 08:00:43 pm »
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 #### helen • LV1 Newcomer (Next: 20) • Posts: 17 • Rating: +1/-0 • KISSY KISSY KISSY LICKY LICKY LICKY ##### Re: How do I create a script that will restart another script after so many minutes? « Reply #2 on: February 09, 2012, 02:23:36 am » 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! Okay sorry it's NOT working.
« Last Edit: February 09, 2012, 01:29:10 pm by helen »

#### helen

• LV1 Newcomer (Next: 20)
• Posts: 17
• Rating: +1/-0
• KISSY KISSY KISSY LICKY LICKY LICKY
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #3 on: February 09, 2012, 01:29:32 pm »
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! Okay sorry it's NOT working. I can't find what the process would be.

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6250
• Rating: +318/-36
• little oof
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #4 on: February 09, 2012, 02:07:27 pm »
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

#### helen

• LV1 Newcomer (Next: 20)
• Posts: 17
• Rating: +1/-0
• KISSY KISSY KISSY LICKY LICKY LICKY
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #5 on: February 09, 2012, 02:08:42 pm »
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 »

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6250
• Rating: +318/-36
• little oof
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #6 on: February 09, 2012, 02:19:03 pm »
Oh it's a php bot? How are you running it?
/e

#### helen

• LV1 Newcomer (Next: 20)
• Posts: 17
• Rating: +1/-0
• KISSY KISSY KISSY LICKY LICKY LICKY
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #7 on: February 09, 2012, 02:20:22 pm »
Oh it's a php bot? How are you running it?
php OmnomIRC.php

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55926
• Rating: +3152/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #8 on: February 09, 2012, 02:22:00 pm »
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)

#### helen

• LV1 Newcomer (Next: 20)
• Posts: 17
• Rating: +1/-0
• KISSY KISSY KISSY LICKY LICKY LICKY
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #9 on: February 09, 2012, 02:23:41 pm »
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? 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.

#### Juju

• Incredibly sexy mare
• Coder Of Tomorrow
• LV13 Extreme Addict (Next: 9001)
• Posts: 5730
• Rating: +500/-19
• Weird programmer
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #10 on: February 09, 2012, 02:28:23 pm »
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?

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.

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55926
• Rating: +3152/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #11 on: February 09, 2012, 02:31:42 pm »
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? 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.

#### Eeems

• Mr. Dictator
• LV13 Extreme Addict (Next: 9001)
• Posts: 6250
• Rating: +318/-36
• little oof
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #12 on: February 09, 2012, 02:40:35 pm »
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

#### DJ Omnimaga

• Former TI programmer
• CoT Emeritus
• LV15 Omnimagician (Next: --)
• Posts: 55926
• Rating: +3152/-232
• CodeWalrus founder & retired Omnimaga founder
##### Re: How do I create a script that will restart another script after so many minutes?
« Reply #13 on: February 09, 2012, 02:42:19 pm »
Ah ok I was wondering, in case he didn't try it.

• Mr. Dictator