Pono
Pono

Reputation: 11836

Delete directory exactly after hour since it was created

In my app I create temp dirs every time user commits a certain action. Is there a chance to somwhow set 'expire' on that dirs? I need to delete those dirs exactly after hour since they were created.

I was thinking about CRONJOB but it will only run once an hour. This will not necessarily delete dirs exactly after one hour.

Thanks in advance.

Upvotes: 1

Views: 64

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 755054

You could use at to schedule the removal of a particular directory. This has the advantage that even if you modify the directory after it is created (adjusting its modify time - the create time is not stored), you will get the correct directory removed. The granularity on at is 1 minute.

Upvotes: 4

Related Questions