0

First of all, sorry if the question doesn't make sense, I'm not the best at English. My question is, I'm trying to save Plink session into a log, that part is now done:

Plink.exe -v -pw [PW] -batch -m C:\BATS\comandosx3.txt root@[IP] > C:\BATS\Logs\outputdegradado.log 2>&1

Now my question is, can I code the output.log name to be stored with date and time so everytime the program starts doesn't write over the last session? for example output2009.log

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • I assume you mean `plink root@IP somecommand > c:\BATS\Logs\output.log 2>&1`, right? – Martin Prikryl Sep 20 '18 at 13:20
  • yes, the full code is: Plink.exe -pw [PW] -batch -m C:\BATS\program.txt root@[IP[ > c:\BATS\Logs\output.log 2>&1 – sergio glez Sep 20 '18 at 13:27
  • 1
    Possible duplicate of [How do I get current datetime on the Windows command line, in a suitable format for using in a filename?](https://stackoverflow.com/questions/203090/how-do-i-get-current-datetime-on-the-windows-command-line-in-a-suitable-format) – Martin Prikryl Sep 20 '18 at 13:32

1 Answers1

0

I didnt know it was related to the batch file, i thought it was plink specific code. Watching for batch specific code, i end up with a single file that registry the date and time at the start of the program.

@echo off
set logfile=C:\BATS\Degradado\Logs\Seguimiento.log
echo starting Plink.exe at %date% %time% >> %logfile%
Plink.exe -v -pw [PW] -batch -m C:\BATS\Degradado\comandosx3.txt root@[IP] oas >> %logfile% 2>&1

Thanks @martin-prikryl for the suggestion