[ILUGC] Re: How to restart a perl script if it is stopped?

  • From: Srinivasan R <srinivasanr@xxxxxxxxx>
  • To: ilugc@xxxxxxxxxxxxx
  • Date: Mon, 25 Jul 2016 11:19:44 +0530

Instead of running that python script in a cron, try using the
python-daemon package to create a daemon script.
https://pypi.python.org/pypi/python-daemon/
$ pip install python-daemon

import daemon

from spam import do_main_program

with daemon.DaemonContext():
    do_main_program()


Thanks & Regards,
Srinivasan R

On Mon, Jul 25, 2016 at 11:10 AM, Kamal Velan <sskamalavelan@xxxxxxxxx>
wrote:

Hi,

If all you want to do is to keep it alive, the following
can help if you don't mind using npm.

https://www.npmjs.com/package/pm2

Thanks,
Kamal

On Mon, Jul 25, 2016 at 11:02 AM, Raman Pandarinathan <raamanp@xxxxxxxxx>
wrote:
On 7/25/16, Shrinivasan T <tshrinivasan@xxxxxxxxx> wrote:
I have a perl script in a desktop which is doing web scrawling
continuously.
when the internet connection goes down sometimes, the script tries for 5
min. Then it dies.

I want the script to run again once the internet is connected,

How can we achieve this?

Better way would be to check connectivity inside the script itself.
Use Net::Ping to test connectivity.
Something like

use Net::Ping;
my $p = Net::Ping->new;

while (1){
    if ($p->ping('ipno you want check',1)){
                  run_your_function();
     )
}

Raman.P
--
blog:http://ramanchennai.wordpress.com/
_____________________________________
ILUGC List: http://www.freelists.org/list/ilugc
ILUGC Web: http://ilugc.in/

_____________________________________
ILUGC List: http://www.freelists.org/list/ilugc
ILUGC Web: http://ilugc.in/




_____________________________________
ILUGC List: http://www.freelists.org/list/ilugc
ILUGC Web: http://ilugc.in/

Other related posts: