crontab in Windows

The Windows Task Scheduler schedules computer tasks to automatically run.

Unlike Linux, the Windows scheduler task does not provide an output log. Instead, you can redirect the log to a specified location of your choice.

The scheduler task calls cmd.exe to run hcismatdbcycle.bat.

The setroot command requires administrator privilege.

Example:

schtasks /create /sc minute /mo 1 /tn "smatdbCycle" /tr powershell 
-Command Start-Process -Verb RunAs C:\The\location\of\hcismatdbcycle.bat

Creating a task:

schtasks /Create
[/S system [/U username [/P [password]]]]
[/RU username [/RP [password]] /SC schedule [/MO modifier] [/D day]
[/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime]
[/RI interval] [ {/ET endtime | /DU duration} [/K]
[/XML xmlfile] [/V1]] [/SD startdate] [/ED enddate] [/IT] [/Z] [/F]

Deleting a task:

schtasks /delete
[/S system [/U username [/P [password]]]] [/TN taskname] [/F]

Deleting example:

schtasks /delete /tn “smatdbCycle” /f

Running a task:

schtasks /run
[/S system [/U username [/P [password]]]] [/TN taskname]

Running example:

schtasks /run /tn “smatdbCycle”

Ending a running task:

schtasks /end
[/S system [/U username [/P [password]]]] [/TN taskname]

Ending example:

schtasks /end /tn “smatdbCycle”

Querying for task Information:

schtasks /query
[/S system [/U username [/P [password]]]]
[/FO format | /XML] [/NH] [/V] [/TN taskname] [/?]

Querying example:

schtasks /query

Changing a task:

schtasks /change
[/S system [/U username [/P [password]]]] /TN taskname
{ [/RU runasuser] [/RP runaspassword] [/TR taskrun] [/ST starttime]
[/RI interval] [ {/ET endtime | /DU duration} [/K] ]
[/SD startdate] [/ED enddate] [/ENABLE | /DISABLE] [/IT] [/Z] }

hcismatdbcycle.bat example

This is a standard example of the hcismatdbcycle.bat file:

@echo off
REM COPYRIGHT 2019 INFOR. ALL RIGHTS RESERVED.
>>C:\the\real\path\task_smatdb.log 2>&1 (
echo Cycle time: %date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
call setroot
call hcismatcycle -s tsmatdbCycle -p smatdb2 -t conn_4 -b out -r C:\company\cis19.1\integrator
call hcismatcycle -s tsmatdbCycle -p smatdb -t conn_2 -b out
...
)

The log is:

Cycle time: 20171228145130
HCIROOT path is C:\company\cis19.1\integrator
No default site -- no site set
Smatdb cycle now.
site name: 'tsmatdbCycle'
process name: 'smatdb2'
thread name: 'conn_4'
in/out: 'out'...
Process command port not defined!
Process is probably not running.
HCIROOT path is C:\cloverleaf\cis6.2\integrator
Smatdb cycle now.
site name: 'tsmatdbCycle'
process name: 'smatdb'
thread name: 'conn_2'
in/out: 'out'...
Response:
outbound message saving cycled