Overwrite file by scheduler task

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
chricken
Posts: 29
Joined: 10 Nov 2017, 15:47

Overwrite file by scheduler task

Post by chricken » 06 Feb 2018, 14:42

Hi,

I have an issue with a scheduler task here:
I am using the scheduler task 'product export', which works fine now.
I get a file, which contains the expected data. Unfortunately the data is being appended to the existing file.
Is there any way to force the script to overwrite the file?

My secondbest idea would be to delete the file a few minutes before it is being written. That'd be okay in my workflow but it is not really clean and beautyful.

Thank you, regards
Christian

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Overwrite file by scheduler task

Post by aimeos » 07 Feb 2018, 10:57

Overwriting the files is not the best idea because this can lead to inconsistencies if they are read and updated at the same time. What would be possible is to add a timestamp to each file so they are not appended any more.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

chricken
Posts: 29
Joined: 10 Nov 2017, 15:47

Re: Overwrite file by scheduler task

Post by chricken » 09 Feb 2018, 05:54

Thanks for your answer,
that's a good objection and i understand, why that is not standard behaviour.

Therefore I already solved that problem by having a second cronjob, which deletes the old file one hour before the new one is generated. For my special usecase, this works perfectly.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Overwrite file by scheduler task

Post by aimeos » 09 Feb 2018, 12:59

The next version will contain the date by default in the file name and the file name template will be configurable so you can decide about the naming of the exported files.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply