使用 tstamp 删除文件开始失败
Using a tstamp to delete files has started failing
我使用 tstamp 构建要删除的旧文件的文件集。这一直运作良好,但从本月初开始就失败了。
错误是:
Date of 08/09/2021 01:25 PM Cannot be parsed correctly. It should be in MM/DD/YYYY HH:MM AM_PM format.
<target name="RemoveOldBackups" >
<tstamp>
<format property="BKRetention" pattern="MM/dd/yyyy hh:mm a" locale="en,UK" offset="-${Backup.Retention.Number}" unit="${Backup.Retention.Unit}"/>
</tstamp>
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<delete>
<fileset dir="${Database.List.@{database}.LocalBackup}" includes="**/*.bkp">
<date datetime="${BKRetention}" when="before"/>
</fileset>
</delete>
</sequential>
</for>
</target>
脚本本身在那段时间没有改变,所以它一定是环境相关的东西。
https://ant.apache.org/manual/Tasks/tstamp.html 在模式中有“aa”而不是“a”。也许值得尝试一下。从我的角度来看,语言环境应该是“en,GB”(或者这是实际问题,应该是 de,DE)。
经过进一步调查,我确定该机器是 运行 2012 年的 Ant 版本。更新到最新版本后,问题已解决。
我使用 tstamp 构建要删除的旧文件的文件集。这一直运作良好,但从本月初开始就失败了。
错误是:
Date of 08/09/2021 01:25 PM Cannot be parsed correctly. It should be in MM/DD/YYYY HH:MM AM_PM format.
<target name="RemoveOldBackups" >
<tstamp>
<format property="BKRetention" pattern="MM/dd/yyyy hh:mm a" locale="en,UK" offset="-${Backup.Retention.Number}" unit="${Backup.Retention.Unit}"/>
</tstamp>
<for list="${Database.List}" param="database" parallel="${parallel}" threadCount="${threadCount}">
<sequential>
<echo message="Working on Database: @{database} Full path: ${Database.List.@{database}.Location}${Database.List.@{database}.FileName}" />
<delete>
<fileset dir="${Database.List.@{database}.LocalBackup}" includes="**/*.bkp">
<date datetime="${BKRetention}" when="before"/>
</fileset>
</delete>
</sequential>
</for>
</target>
脚本本身在那段时间没有改变,所以它一定是环境相关的东西。
https://ant.apache.org/manual/Tasks/tstamp.html 在模式中有“aa”而不是“a”。也许值得尝试一下。从我的角度来看,语言环境应该是“en,GB”(或者这是实际问题,应该是 de,DE)。
经过进一步调查,我确定该机器是 运行 2012 年的 Ant 版本。更新到最新版本后,问题已解决。