run a script every 4 hours with task scheduler - windows

I have windows 2008 task scheduler I set up a PHP script to run like this
C:\php\php.exe -f etc...
In windows task scheduler I can only schedule daily or hourly how can I configure it to run every 4 hours?

In Windows Server 2008/2008R2 you can set task to repeat every number of hours you want, corresponding drop down menu just present you with 1 hour option to select, but you can type in any number of hours you need (see screenshot below).

You could just set it up to run every hour, and at the beginning of the PHP script, check the current time, and exit if the current hour modulus 4 wasn't zero.
Where it says "repeat task every", you may also just be able to change "1 hour" to "4 hours" (it's not in the dropdown, so just type it in). You can do this in Windows 7, I'm not sure about Windows Server 2008.

Related

What is "INTERVAL=0" means in Oracle Schedular?

My Oracle DBA have setup a task with following repeat_interval:
Start Date :"30/JAN/20 08:00AM"
Repeat_interval: "FREQ=DAILY; INTERVAL=0; BYMINUTE=15"
Can I ask what is "Interval=0" means?
Does it means this task will run daily from 8AM, and will repeat every 15 mins until success?
I tried to get the answer from Google, but what I find is what is Interval=1, but nothing for 0.
So would be great if anyone can share me some light here.
Thanks in advance!
INTERVAL is the number of increments of the FREQ value between executions. I believe in this case that a value of 0 or 1 would be the same. The schedule as shown would execute once per day (FREQ=DAILY), at approximately 15 minutes past a random hour (BYMINUTE=15, but BYHOUR and BYSECOND are not set).
Schedule has nothing to do with whether or not the previous execution succeeded or not. Start Date is only the date at which the job was enabled, not when it actually starts processing.
If you want it to run every 15 minutes from the moment you enable it, you should set as follows:
FREQ=MINUTELY; INTERVAL=15
If you want it to run exactly on the quarter hour, then this:
FREQ=MINUTELY; BYMINUTE=0,15,30,45; BYSECOND=0
If you want it to run every day at 8am, then this:
FREQ=DAILY; BYHOUR=8; BYMINUTE=0; BYSECOND=0

How can we schedule nifi data flow ? I'm using HDP 2.5

I want to schedule data flow in daily base through nifi.
For Example,
I need to run schedule on 9.00 AM in every morning.
Can anyone tell me what is procedure to make schedule data flow
There are three scheduling strategy available, see below details
Timer driven: This is the default mode. The Processor will be scheduled to run on a regular interval. The interval at which the Processor is run is defined by the ‘Run schedule’ option (see below).
Event driven: When this mode is selected, the Processor will be triggered to run by an event, and that event occurs when FlowFiles enter Connections feeding this Processor. This mode is currently considered experimental and is not supported by all Processors. When this mode is selected, the ‘Run schedule’ option is not configurable, as the Processor is not triggered to run periodically but as the result of an event. Additionally, this is the only mode for which the ‘Concurrent tasks’ option can be set to 0. In this case, the number of threads is limited only by the size of the Event-Driven Thread Pool that the administrator has configured.
CRON driven: When using the CRON driven scheduling mode, the Processor is scheduled to run periodically, similar to the Timer driven scheduling mode. However, the CRON driven mode provides significantly more flexibility at the expense of increasing the complexity of the configuration. The CRON driven scheduling value is a string of six required fields and one optional field, each separated by a space.
You typically specify values one of the following ways:
Number: Specify one or more valid value. You can enter more than one value using a comma-separated list.
Range: Specify a range using the - syntax.
Increment: Specify an increment using / syntax. For example, in the Minutes field, 0/15 indicates the minutes 0, 15, 30, and 45.
You should also be aware of several valid special characters:
* — Indicates that all values are valid for that field.
?  — Indicates that no specific value is specified. This special character is valid in the Days of Month and Days of Week field.
L  — You can append L to one of the Day of Week values, to specify the last occurrence of this day in the month. For example, 1L indicates the last Sunday of the month.
For example:
The string 0 0 13 * * ? indicates that you want to schedule the processor to run at 1:00 PM every day.
The string 0 20 14 ? * MON-FRI indicates that you want to schedule the processor to run at 2:20 PM every Monday through Friday.
The string 0 15 10 ? * 6L 2011-2017 indicates that you want to schedule the processor to run at 10:15 AM, on the last Friday of every month, between 2011 and 2017.
For your schedule time should be like below;
0109*?** - this meaning every 1 seconds 09 minutes is morning 9 AM other * fields run every day and month.
I hope it helps you!!!
Scheduling Strategy: CRON driven
Run Schedule: 0 0 9 * * ? *

How to restrict windows tasks to weekdays only?

I have a task that triggers on "user session logon". I now want to restrict that task to fire only on weekdays, and being ignored on the weekend.
Is that possible?
Sidenote: I cannot use the trigger on schedule as I do not want to run the task periodically, but only on logon, and only on weekdays.
click Weekly (NOT Daily)
Choose the days you want
As far as I understand, this is not possible using the task scheduler alone.
You could use a piece of VBScript to achieve this.
Set up a file, e.g. mytask.vbs, like this:
If DatePart("w", Date, vbMonday) < 6 Then
Set Shell = CreateObject("WScript.Shell")
WScript.Quit(Shell.Run("C:\Windows\System32\notepad.exe", 10, True))
End If
Replace notepad by the task you actually want to run. What this things does is: It checks whether the current day is Mo-Fr (this is done by specifying the start of the week as Monday, so DatePart will return values from 1=Monday to 7=Sunday, and then we're checking if it's below 6), and if yes, it runs a certain program, waits for it to finish and forwards its exit code. (The magic number 10 here means that it will respect whatever setting for window display (normal, maximized, minimzed) was passed by the task scheduler, if any, and also forward it to the program.)
Then you can create a scheduled task with a logon trigger only, which runs wscript.exe /e:vbscript c:\path\to\your\mytask.vbs. That's it!

Delay activity not always working in Sharepoint 2010 workflow

Currently we have a sequential workflow in sharepoint 2010 that has a delay activity.
The delay is set to five minutes. The workflow checks on the status of five tasks and depending on the results, it either delays or completes.
I have a workflow history log item set to write right before the delay and right after the delay.
Sometimes the delay does not fire, an example would be as follows:
Delay activity fires every five minutes for 3 full days on one item, then for no particular reason it fails to wake up for 17 hours...then fires and completes.
Any ideas? I have verified all of the timer services are running properly etc.
The other odd thing is that there can be 20 workflows items running and only 4 or 5 will have this issue, it seems totally random.
Also: If I make a change to the workflow item that causes the workflow to re-run, the delay activity will awaken at the next 5 minute cycle.
Update: I have found an error in my error log that occurs when the delay fails to awaken.
Workflow ID=07acf527-d5cb-41c7-a8e4-58329652dc53 attempting to run on a thread currently executing workflow ID=fe2d7670-7d3e-4e6a-b024-0cc3485aa73b. This workflow will be run at a later time.
Update: Apparently this is occurring because the workflow with the delay is being started programmatically from another workflow. This causes the second workflow to be started in the same thread. Anyone know how to specify a new thread programmatically?
Update 2: I setup some workflows to run with a 5 minute delay to see if there was any pattern to the sleep cycles. The workflows slept at 5 minute intervals for around 6 hours then the timer started to increment as follows
5 minutes
15 minutes
45 minutes
1.5 hours
3 hours
6 hours
12 hours
It looks like the delay timers are being doubled for the most part. I sure MS can figure this one out, I have tons of logs and examples.
This issue has been resolved. I had forgotten to post the resolution...
Three settings needed to be modified. Workflow Throttle, Workflow Batch, and the Hidden Workflow Timer.
You can check the current throttle setting by running the following command:
stsadm -o getproperty -pn
workflow-eventdelivery-throttle
Here is my new setting:
stsadm -o setproperty -pn
workflow-eventdelivery-throttle -pv
"45"
You can check the current batch size setting by running the following command:
stsadm -o getproperty -pn
workitem-eventdelivery-batchsize
Here is my new setting.
stsadm -o setproperty -pn
workitem-eventdelivery-batchsize -pv
"250"
You can check the current interval setting by running the following command, in which you replace the URL with a valid path to a SharePoint application:
stsadm -o getproperty -pn job-workflow
-url http://yoursiteurl
Here is my setting:
stsadm -o setproperty -pn job-workflow
-pv "Every 5 minutes between 0 and 59" -url http://yoursiteurl

Scheduling a task to run at the end of every month. (Windows Server 2003 - Scheduled Tasks)

I need to schedule a task to run on the last night of each month, on a Windows 2003 Server.
I see that you can schedule it to run on the "first or last Mon-Fri", or even on the nth day of each month - but, not how to get it to run on the last day (regardless of day of the week or number).
Thanks in advance.
Note: I did check "How do you schedule tasks in Windows?", etc...
Looks like you have to set up multiple schedules for your task. One schedule for the months with 31 days, another for those with 30, and one more for February. See this: http://support.microsoft.com/kb/936627
I do it a little differently - I run one task every day but since the task is in vbscript - I do this:
DIM datecur, datefut
datecur = DATEPART("m",NOW())
datefut = DATEPART("m",NOW()+1)
If (datecur <> datefut) then
'insert code you want to run here
end if
Simple and it works - hope this helps someone
As of November 2022, much newer Windows version (2019)
I see this option in Triggers:
WinScheduler Task Triggers
Begin the task: On a schedule
Settings:
Monthly
On: Last > then select All weekdays

Resources