Timestamp problems

Advertisement

Freitag
Freitag avatar
Joined:
Posts:
75

Timestamp problems

I have read several of the previous conversations about how to preserve timestamps and I still can't get mine to make sense.

I have a hosting service and I am not the root admin. If I create a file on that system and use THEIR web tool to examine the file metadata I see a timestamp of "5:29 PM" – I have to alter how WinSCP and PuTTY see the file to match that timestamp. This timestamp is correct for my local time of US CDT – so they are doing something to translate that in the web page UI.

In WinSCP I am connected via SFTP. I am using an ini file. In that ini file I have PreserveTime=1
In the Explorer view the file timestamp is "10/20/2022 4:29:08 PM". It is showing 1 hour earlier.

I cannot change the hosts opinion of what time it is. The date command (PuTTY) results in:
Thu Oct 20 15:29:45 PDT 2022
And I cannot change that they think it is PDT

I am launching my WinSCP connection from KeePass using
cmd://"WinSCP.exe"  /ini="%USERPROFILE%\Documents\Config Files\WinSCP\mysettings.ini" "sftp://{USERNAME}:{PASSWORD}@{URL}"
The hosting company is Dreamhost if that makes a difference.

As a separate problem, PuTTY shows the file as "Oct 20 15:29" – I am opening PuTTY by clicking on the PuTTY button in the WinSCP toolbar. This is showing the file timestamp as 2 hours earlier. I figure that changing that is out of scope for a WinSCP help forum, but just in case someone else had the same problem and fixed it, I include it.

Short version: I want WinSCP, PuTTY, and the hosting company web GUI to agree about the timestamp of a single file. What do I change in my ini file, connection string, or whatever I need to touch in order to make that happen?

Reply with quote

Advertisement

Freitag
Freitag avatar
Joined:
Posts:
75

Thanks! Here is the log file.

My ID and PW are stored in KeePass so it launches WinSCP by command line and I have a referenced .ini file.

Our DST will end on November 6 this year (I just wish they'd stop messing with the clocks it causes so much pain in my own code).

I cannot make server changes other than environment variables. :(
Here is an output from the timedatectl command done at MY local time of 2022-10-26 02:41 (AM)
They are on CDT
$  timedatectl
                      Local time: Wed 2022-10-26 00:40:22 PDT
                  Universal time: Wed 2022-10-26 07:40:22 UTC
                        RTC time: Wed 2022-10-26 07:40:22
                       Time zone: America/Los_Angeles (PDT, -0700)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no
Description: Log file

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

The server claims (unless WinSCP logging is broken) that the timestamp of the timeTesting file is 2022-10-26 04:56:48 UTC. That does not correspond to the times in your original post anyhow, so I cannot advice any further. If you post Debug 2 level log, I can check further if WinSCP decodes the time correctly. But I'm sure it does.

WinSCP does not offer any way to adjust times for SFTP protocol, as the SFTP server is mandated by the SFTP specification to use UTC times. So there's no room for any need for adjustments.

Reply with quote

Freitag
Freitag avatar
Joined:
Posts:
75

I'm pretty sure the server default is PDT (America/Los_Angeles) although by setting the TZ variable I can force PuTTY to show me the expected time when I ls -l.

I can connect with SCP instead. When connecting by SCP I do see a different time (but still not the expected one). When I expect 10:27 I see instead 07:27 (when using Adjust remote timestamp with DST) or 08:27 (when using Adjust remote timestamp to local conventions). The Preserve timestamp is greyed out and unavailable.

I do see if I am using WinSCP to store my connection info I can go into the env settings for SCP/Shell and click a checkbox to "Try to get full timestamp" and also on the main settings to adjust with local convention/DST – are those settings available in an ini file? (I am not storing credentials in WinSCP, I am starting it by command line, but I have full control over the ini file)

Reply with quote

Advertisement

Freitag
Freitag avatar
Joined:
Posts:
75

I think that has nailed it. My Override URL command line in KeePass now is
cmd://"WinSCP.exe" /ini="%USERPROFILE%\Documents\Config Files\WinSCP\domain.ini" "scp://{USERNAME}:{PASSWORD}@{URL}" /rawsettings  ConsiderDST=2
And all of the timestamps match between the three different ways of viewing (ls -l in PuTTY, the Web based GUI provided by the hosting company).

Thanks for the help!

For anyone else that reads this later. This solves the problem of the remote server having a timestamp setting that a) isn't what it says it is and b) can't be changed by the user. Leading to the problem that the answer to the question of "what time was this file created?" depends on how you have looked at it in WinSCP or PuTTY or some third way of listing files.
In my case the third way is the "right" answer (I is not right, but everything else must match it).
In PuTTY it is solved by setting the TZ environment variable to some value that just makes it work, not necessarily the time zone of your location!
And in WinSCP with the answer that Martin provided.

Fingers crossed that when DST ends I don't have to change my command line – but at least I have a head start on where to look.

Reply with quote

Advertisement

You can post new topics in this forum