I know there are some other questions about this, but how do I set the task scheduler to open a file/program every x minutes starting right after the task was ran.
I'm making a program that has a script that has to be ran every 3 minutes and the best way is the task scheduler.
I have tried messing with the settings and I found "Repeat task every x minutes" but the problem with that is I have to set the starting time and I don't want that. I want it to start repeatin the task as soon as it was started.
Thanks!
You could combine a task that runs on login with a batch script that loops endlessly running the program you want every 3 minutes.
Related
In Windows task scheduler I have a task. For example: Test
Under that, I have 3 actions.
Problem is all 3 actions execute at the same time.
I have a requirement that each actions starts only after the previous one ends.
Is there way we can set these conditions?
I need to schedule a Task inside of my Windows server 2016 to run every minute, how would one accomplish that?
I've tried Task Scheduler->Create Task, but the minimum is every 5 minutes,
Is it to possible to schedule task (run exe) every minute ?
any ideas? thanks!
You can set 1 minute frequency through task scheduler itself. The option does not appear in the dropdown list, but you can edit the text and it will accept a variety of values from 1 minute upwards.
I have a script that must run at a certain hour for the amount of time I specify.
I'm looking at the clockwork gem (https://github.com/tomykaira/clockwork) which seems to be the closest piece of software I might eventually use to accomplish this, unfortunately it doesn't seem to give the ability to set a duration (start at 3PM stop 5PM), meaning I have to split the feature in 2, starting the script is going to be clockwork's job, stopping it is in the script itself with a custom solution.
Very suboptimal and messy.
How does people do this in Ruby? TIA
There is great gem called whenever for same job. With it you can set exact time for your task, like:
every 1.day, :at => '4:30 am' do
runner "MyModel.task_to_run_at_four_thirty_in_the_morning"
end
But you'll have to have two stages, one for starting one for stopping your job, which seems to be more natural than job which kills itself at some time by my opinion.
Somewhat janky, but there is another solution. I'm not sure what you are using to host your app, but on Heroku you can set up a scheduler to run every 10 minutes, on the hour, or daily. Then inside the method that the scheduler calls, you can determine the current time. Say you only want to run it between 3pm and 5pm, you would just wrap your code inside an if statement that verifies the current time is between 3pm and 5pm (watch out for time conversions with UTC).
Hope this helps.
All,
I need to schedule a task (batch script) to run once per minute, every day.
Looking at the Task Scheduler, I see the minimum repeat interval for a task is 5 minute, which is located in the "Trigger" window dropdown.
How do you do this in the Task Scheduler?
Thanks Much
The dropdown box is editable so just change the value to "1 minute"
I have to set up a cron job on my hosting provider.
This cron job needs to run every second. It's not intensive, just doing a check.
The hosting provider however only allows cron jobs to be run every two minutes. (can't change hosting btw)
So, I'm clueless on how to go about this?
My thoughts so far:
If it can only run every two minutes, I need to make it run every second for two minutes. 1) How do I make my script run for two minutes executing a function every second?
But it's important that there are no interruptions. 2) I have to ensure that it runs smoothly and that it remains constantly active.
Maybe I can also try making it run forever, and run the cron job every two minutes checking whether it is running? 3) Is this possible?
My friend mentioned using multithreading to ensure it's running every second. 4) any comments on this?
Thanks for any advice. I'm using ZF.
Approach #3 is the standard solution. For instance you can have the cron job touch a file every time it runs. Then on startup you can check whether that file has been touched recently, and if it has then exit immediately. Else start running. (Other approaches include using file locking, or else writing the pid to a file and on startup check whether that pid exists and is the expected program.)
As for the one second timeout, I would suggest calling usleep at the end of your query, supplying the number of milliseconds from now to when you next want to run. If you do a regular sleep then you'll actually run less than once a second because sleeps sometimes last longer than expected, and your check takes time. As long as your check takes under a second to run, this should work fine.
I don't think cron allows second level resolution. http://unixhelp.ed.ac.uk/CGI/man-cgi?crontab+5
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sun, or use names)
So, even if your hosting provider allows you can't run a process that repeats every second. However, you can user command something like watch for repeated execution of your script. see here