Overview
Scheduling
Operational scheduling, planned jobs, and temporal orchestration.
Scheduled Task Management
The Scheduler module executes planned jobs by reading the configuration from the dbo.scheduler metadata table and tracking outcomes in dbo.scheduler_execution.
Description: the service periodically checks due tasks, executes the command, and updates execution states.
Runtime flow:
- periodic backend poll (Hosted Service) on tasks with
enabled = 1andnext_execution <= now. - task execution based on the configured action type.
- outcome recording (
ok/error, duration, message) toscheduler_execution. - update of
last_execution,next_execution,last_ex_succededfields.
scheduler Table Metadata (Main Fields)
id: task identifier.enabled: enables/disables the job.event_name: logical name of the scheduled event.month_interval,day_interval,hour_interval,minute_interval,second_interval: combinable intervals used to calculate the next execution.action_type: operation type executed by the job.action_cmd: command associated with the action type.last_execution: last execution timestamp.next_execution: next planned execution timestamp.last_ex_succeded: last outcome flag (true/false).
Action Types (action_type) and Meaning
Snippet (quick map):
1 | sql -> SQL / stored procedure2 -> web service3 -> .NET method (Namespace.Type.Method)4 -> mailing/distribution list
1orsql: executes SQL/stored procedure.2: invokes a web service endpoint.3: invokes a .NET method (Namespace.Type.Method) via reflection.4: executes a mailing/distribution list action.
Web service (action_type = 2): absolute or relative URL
action_cmd has the form [VERB] url: the verb (GET, POST, PUT, DELETE, PATCH) is optional and without it the call is a POST. params_values goes into the body (JSON or form) or, for GET/DELETE with key=value pairs, into the query string.
Snippet:
POST http://localhost:5100/api/invoices/reminders-> absolute URL, called as is.POST /api/invoices/reminders-> URL relative to the app (since 1.7.32).GET /api/warehouse/stock-> relative,GETmethod./api/report/nightly-> relative,POSTmethod.
A relative URL (starting with /) is resolved on the address of the running app, so the job does not depend on the host and port of the installation:
1. if Scheduler.TrustedAuthBaseUrls is configured, on its first URL, including the path (e.g. http://localhost/CrmApp);
2. otherwise on an address the process listens on with a wildcard or loopback host (http preferred over https): with Kestrel for example http://localhost:5000 (also behind nginx, which is not traversed), with IIS in-process including the sub-application path (http://localhost:80/CrmApp);
3. if neither can be used (unix socket, only non-loopback addresses, IIS out-of-process) the job fails with an error asking to set Scheduler.TrustedAuthBaseUrls. Set it also when the IIS site answers only to a host name (host header binding): e.g. ["https://crm.example.com/CrmApp"].
A relative URL cannot leave the app: //host/..., backslashes and paths that leave the sub-application (/../OtherApp/...) are rejected. The login of the __scheduler service user and its cookie go only to this backend (loopback host on a listening port or a URL listed in Scheduler.TrustedAuthBaseUrls), for relative and absolute URLs alike; towards other hosts the call is sent without credentials.
Execution Tracking (scheduler_execution)
For each run, at least the following is recorded:
- reference to the scheduled task.
- start and end date/time.
- final status.
- optional error message or summary output.
This enables operational auditing and job troubleshooting.
Relevant AppSettings
Description: these keys govern the polling cycle, per-cycle concurrency, and SQL timeouts.
Snippet:
"Scheduler.Enabled": true"Scheduler.PollSeconds": 15"Scheduler.MaxTasksPerCycle": 20"Scheduler.RetryDelaySeconds": 60"Scheduler.SqlCommandTimeoutSeconds": 300"Scheduler.TrustedAuthBaseUrls": ["http://localhost/CrmApp"]
Enabled: enables/disables the backend scheduler.PollSeconds: polling frequency for due tasks.MaxTasksPerCycle: maximum number of tasks processed per cycle.RetryDelaySeconds: minimum delay before retry after error.SqlCommandTimeoutSeconds: timeout for scheduler SQL commands.TrustedAuthBaseUrls(optional, empty by default): URLs of this app, besides loopback, to which the scheduler may send the__schedulerlogin and cookie; the first one is also the base of the relative URLs of webservice jobs.
Result:
- predictable and controllable scheduling per environment;
- simple tuning of frequency, throughput, and error robustness.
Screenshot
