i just have the following command in cmd
perl csv2rrd3.pl
but it always run for a long time. Is there any way to set a timeout for it? or i should do it in the perl script?? And how?
Thanks
Inside of Perl, you can set an alarm to go off after a few seconds. You can then use a signal handler to catch the event. Only one alarm may be active at any time
{ # enter new scope
# set signal handler
local $SIG{ALRM} = sub {
# do cleanup, like closing sockets or whatever
print STDERR "exited with ALARM\n";
exit;
};
alarm 30; # try half a minute
...; # do expensive stuff
}
From the windows command line, you can first start
the perl script in its own window, chain it with the timeout
command to wait x seconds (here 2) and then chain it again with the taskkill
command to kill the process.
start perl csv2rrd3.pl & timeout -t 2 & taskkill /IM perl.exe
The line above would kill every perl process. To kill only your just started one, you could use a custom window title.
start "KILLME" perl csv2rrd3.pl & timeout -t 2 & taskkill /FI "WINDOWTITLE eq KILLME" /IM perl.exe
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With