Link to home
Start Free TrialLog in
Avatar of Sevy0622
Sevy0622

asked on

Scheduling remotet tasks

I support servers across the country and have a few processes that allow me
to execute tasks on all the servers using scheduled tasks. A script runs
through a server OU and creates a CMD file that looks like this....  (
simplified )

    at \\server1 4:00 d:\utils\process.cmd
    at \\server2 4:00 d:\utils\process.cmd
    at \\server3 4:00 d:\utils\process.cmd
    at \\server4 4:00 d:\utils\process.cmd
    ..
    ..

Executing this CMD file then schedules process.cmd to run on all servers at 4:00 AM.

There is one process in particular that I would like to have run at the same
time on all servers, but when the tasks are scheduled using the AT command
as seen above, the task runs on local time. Since my servers span the
country, several time zones are crossed.

Is there a way using AT or SCHTASKS that tasks can be scheduled to run at the same time (GMT) even though they cross time zones?

A simple "NO" answer gets you 50 points.
A "YES" and help to solve this will earn between 125 and 250 depending on the difficulty.



Avatar of NJComputerNetworks
NJComputerNetworks
Flag of United States of America image

no, I think you will have to script custom kick off times... You can either manually organize your servers into time zone and edit the script for the proper kick off time, or device a mechanism to check the system time zone before running the AT.
ASKER CERTIFIED SOLUTION
Avatar of cbeee
cbeee

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sevy0622
Sevy0622

ASKER

Raising the point value for solution
This worked with a little engineering.

Using psexec like
     psexec @DCList.txt \\rmtserver\rmtshare\script.cmd
will execute the script on all the servers, however, the process runs through the list of DCs in the text file, running the script against each server consecutively. This gets the script run on all servers, but when I have about 60 DCs in the list, and the process runs between 2-3 minutes on each server, that makes for a two to three hours time difference for the execution on the first and last servers.

...so...

I modified my script to create the CMD file....
     psexec \\server1 \\rmtserver\rmtshare\script.cmd
     psexec \\server2 \\rmtserver\rmtshare\script.cmd
     psexec \\server3 \\rmtserver\rmtshare\script.cmd
     ..

Thanks for your help!!!
     ..
So when I execute my CMD file, the script gets remotely launched on all DCs at the same time.

FYI ...   Below is a script which I received to this question  from a news group. It uses a method where you determine the time zone offset for each server and adjust the execution time for the AT command. This is very interesting and something I will spend some time working with too.


    Save the following as sGMT.bat:

    @echo off
    if {%4}=={} @echo Syntax: Call sGMT \\Server GMT_Hour_2_Schedule GMT_Minute_2_Schedule FQFN&goto :EOF
    setlocal
    set key=%1\HKLM\System\CurrentControlSet\Control\TimeZoneInformation
    for /f "Tokens=3" %%a in ('reg query %key% /V ActiveTimeBias^|FIND "REG_DWORD"') do (
       set /a off=%%a
    )
    if %off% GEQ 0 goto pos
    set /a off=0 - %off%
    set /a oh=%off% / 60
    set /a om=%off% - (%oh% * 60)
    set /a oh=24 - %oh%
    set /a sh=%2 + %oh%
    set /a sm=%3 + %om%
    if %om% NEQ 0 set /a sh=%sh% - 1
    goto :OK
    :pos
    set /a oh=%off% / 60
    set /a om=%off% - (%oh% * 60)
    set /a sh=%2 + %oh%
    set /a sm=%3 + %om%
    :OK
    if %sm% LSS 10 set sm=0%sm%
    AT %1 %sh%:%sm% %4

Then, in your batch

    call sGMT \\server1 4 0 d:\utils\process.cmd
    call sGMT \\server2 4 0 d:\utils\process.cmd
    call sGMT \\server3 4 0 d:\utils\process.cmd
    call sGMT \\server4 4 0 d:\utils\process.cmd