0

I have written a perl script which i try to call every 1 minute from a batch file.

There is no error but it do not call it every 1 minute. It just pop command prompt when clicked once on .bat file. My code to do is this: (batchTestShe.bat) the ccc.pl and batchTestShe.bat are in same folde and ccc.pl runs only once i click on batchTestShe.bat but never repeats execution.

schtasks /create /tn "batch Script" /tr C:\shekhar_Axestrack_Intern\WindowCreation\batchTestShe.bat /sc minute /mo 1 
perl C:\shekhar_Axestrack_Intern\WindowCreation\ccc.pl

I can see on taskschd.msc it show it's nect execution next minute but do not pop up command prompt next minute. WHY any idea ?

And please note that i also do not want something message at prompt like . This file already exist do you wanna rename it Y/N ? I want just running it every minute non stopingly.

7
  • 1
    Why not pause your perl script for a minute and loop? – LPChip Jan 19 '15 at 20:15
  • What are the contents of finals.bat? – Foosh Jan 19 '15 at 20:18
  • @Foosh that was batchTestShe.bat sorry my mistake (the file itself) – user3085082 Jan 20 '15 at 4:37
  • @LPChip COULD YOU PLeae give me the basic body of repeating that way every minute ? – user3085082 Jan 20 '15 at 4:38
  • My perl is rusty. It has been years ago since I programmed in it. But I'm pretty sure google knows the answer. – LPChip Jan 20 '15 at 11:27
0

If all your batch script does is call the Perl script every 60 seconds, then you can put the logic in your Perl script itself and reduce some clutter.

#!perl

while(1){

...

Your code here

...

sleep(60);
}

If you need more advanced scheduling you can even use a module like https://metacpan.org/pod/EV::Cron to enable Cron-ish job scheduling in your system.

0

You have a batch file that is re-creating the same scheduled task over and over. You could avoid creating the scheduled task and just make this your batch file:

:START
    perl C:\shekhar_Axestrack_Intern\WindowCreation\ccc.pl
    timeout /t 60
goto :START

Or, wrap your perl script in a while loop to run every 60 seconds:

while (1) {
    sleep 60;
    your ccc.pl code goes here;
}

Those solutions will result in drift since they take (60 seconds + script execution time) to run. If you need it to run exactly every 60 seconds, stick with the task scheduler approach, but try launching your perl script directly rather than through a batch file. Also make sure your script doesn't take longer than 60 seconds to run or you could end up with multiple instances running in parallel.

schtasks /create /tn "run ccc.pl once a minute" /tr "perl C:\shekhar_Axestrack_Intern\WindowCreation\ccc.pl" /sc minute /mo 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.