问题描述:

I've got a property file which is read several times per day by an external application in order to process some files. One of the properties tells the app where to store the processed files. Application runs on Linux.

success_path=/u02/oapp/success

The problem is that every day several files are thrown in that path and after several months, I would have thousands of files in this plane folder.

Question: How can I append the current date to this property file so it would look like:

success_path=/u02/oapp/success/dd-MMM-yyyy

This would be updated every day at 12:00AM so for example today it would be

success_path=/u02/oapp/success/28-JAN-2017

The file is /u02/oapp/configuration/oapp.properties

Thanks in advance

网友答案:

Instead of appending current date to the property, add additional logic to the code that stores the processed files so that:

  • it takes the base directory from the property file (success_path in your case)
  • it creates a year/month/day directory to store the files

Something like:

/u02/oapp/success/year/month/day (as in `/u02/oapp/success/2017/01/01`)
or
/u02/oapp/success/yearmonth/day  (as in `/u02/oapp/success/201701/01`)
or
/u02/oapp/success/yearmonthday   (as in `/u02/oapp/success/20170101`)

If you don't have the capability to change the app's behavior, you might need to write a cron job that periodically moves the files external to the app.

相关阅读:
Top