I'm trying to "build" a batch that's a kind of Linux cron job, with the schedules inside the batch.
From Monday to Friday, a command runs at 7:00 AM, 1:00 PM, and 8:00 PM, while on Saturday and Sunday, it runs only at 1:00 PM.
I'm trying every possible combination, but I can't get the iff to work (bold row, hour 24h format, tDAY = 1 - Sunday).
@echo off
do forever
set tDAY=%_dowi
set tHOUR=%_hour%%_minute%%_second%
printf "{TEST} %s %02d/%02d/%4d %02d:%02d:%02d - START\n" %_DOW %_DAY %_MONTH %_YEAR %_HOUR %_MINUTE %_SECOND
printf "{TEST} %s\n" %tHOUR
echo %@eval[%tHOUR] %@eval[130000]
iff %@eval[%tHOUR] ge %@eval[200000] then
if %tDAY% == 1 .or. %tDAY% == 2 .or. %tDAY% == 3 .or. %tDAY% == 4 .or. %tDAY% == 5 (
printf "{TEST} Wait until 07:00\n"
delay until 07:00
rem Commands to execute
printf "{TEST} Command execute 07:00\n"
)
elsiff %@eval[%tHOUR] ge %@eval[130000] then
if %tDAY% == 1 .or. %tDAY% == 2 .or. %tDAY% == 3 .or. %tDAY% == 4 .or. %tDAY% == 5 .or. %tDAY% == 6 (
printf "{TEST} Wait until 20:00\n"
delay until 20:00
rem Commands to execute
printf "{TEST} Command execute 20:00\n"
)
elsiff %@eval[%tHOUR] ge %@eval[070000] then
printf "{TEST} Wait until 13:00\n"
delay until 13:00
rem Commands to execute
printf "{TEST} Command execute 13:00\n"
endiff
printf "{TEST} %s %02d/%02d/%4d %02d:%02d:%02d - STOP\n" %_DOW %_DAY %_MONTH %_YEAR %_HOUR %_MINUTE %_SECOND
printf "%s\n" %@repeat[=,80]
enddo
Any hint?
From Monday to Friday, a command runs at 7:00 AM, 1:00 PM, and 8:00 PM, while on Saturday and Sunday, it runs only at 1:00 PM.
I'm trying every possible combination, but I can't get the iff to work (bold row, hour 24h format, tDAY = 1 - Sunday).
@echo off
do forever
set tDAY=%_dowi
set tHOUR=%_hour%%_minute%%_second%
printf "{TEST} %s %02d/%02d/%4d %02d:%02d:%02d - START\n" %_DOW %_DAY %_MONTH %_YEAR %_HOUR %_MINUTE %_SECOND
printf "{TEST} %s\n" %tHOUR
echo %@eval[%tHOUR] %@eval[130000]
iff %@eval[%tHOUR] ge %@eval[200000] then
if %tDAY% == 1 .or. %tDAY% == 2 .or. %tDAY% == 3 .or. %tDAY% == 4 .or. %tDAY% == 5 (
printf "{TEST} Wait until 07:00\n"
delay until 07:00
rem Commands to execute
printf "{TEST} Command execute 07:00\n"
)
elsiff %@eval[%tHOUR] ge %@eval[130000] then
if %tDAY% == 1 .or. %tDAY% == 2 .or. %tDAY% == 3 .or. %tDAY% == 4 .or. %tDAY% == 5 .or. %tDAY% == 6 (
printf "{TEST} Wait until 20:00\n"
delay until 20:00
rem Commands to execute
printf "{TEST} Command execute 20:00\n"
)
elsiff %@eval[%tHOUR] ge %@eval[070000] then
printf "{TEST} Wait until 13:00\n"
delay until 13:00
rem Commands to execute
printf "{TEST} Command execute 13:00\n"
endiff
printf "{TEST} %s %02d/%02d/%4d %02d:%02d:%02d - STOP\n" %_DOW %_DAY %_MONTH %_YEAR %_HOUR %_MINUTE %_SECOND
printf "%s\n" %@repeat[=,80]
enddo
Any hint?