Set date and time of a Linux device from a Windows batchfile

I had a client with Linux device that whose clock is not as reliable as it should be, running a time-critical application.

As a workaround fix I wrote a Windows batchfile to update the Linux date and time, and  he has set up a windows scheduled task to run it every morning:

set Day=%date:~0,2%
set Month=%date:~3,2%
set Year=%date:~6,4%

set Hour=%time:~0,2%
set Minute=%time:~3,2%
set Second=%time:~6,2%

@C:path_to_plinkplink.exe -ssh -pw linux_password linux_user@192.168.0.1 date %Month%%Day%%Hour%%Minute%%Year%.%Second%

Once again I have utilised one of the free PuTTY tools (plink.exe): http://www.chiark.greenend.org.uk/~sgtatham/putty/

Posted in General Tagged with: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*