2

There are some retention policies for the data that my company uses. For different types of data, we have different rules and these different types of data and files are used in different microservices and databases.

For example :

  • file type "A" should get deleted after 30 days,
  • file type "B" should get deleted after 100 days,
  • and file type "C" should get deleted after 7 days.

We have a job that should delete these files for each microservice.

I want to test this cron job (automated, not manual) and make sure our data would get deleted at the right time. I need to do it with the bare minimum amount of work (kinda in a hurry), and I don't want to use an approach that may cause us liability issues and security issues. What should I do?

1 Answer 1

1

Right now, the way the question reads, it sounds like the OP wants one cron job to handle the file deletion.

In this scenario, you're not really testing a cron job, but ensuring the files get deleted. Cron jobs have been around a long time and tend to just work if setup correctly. They run whatever you want at a specified time and interval.

What I'd do is setup multiple cron jobs, one for each type of file that needs to be deleted at a specific time. You can test the setup of the cron job on some random files at a smaller interval, say 10 minutes or 1 hour, to ensure accuracy. If that works, adjust the times accordingly.

I could also argue that this question might be better asked in DevOps or ServerFault.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.