hi ,

all i want to delete files after xx days from a folder using php

thnx in adv..

Recommended Answers

Hi,

Here's another option, try using cron jobs.

find /yourdir/tmp -mtime +1-exec rm {}

1 is the xx days.

Regards,
Al

Jump to Post

All 8 Replies

Hi,

Here's another option, try using cron jobs.

find /yourdir/tmp -mtime +1-exec rm {}

1 is the xx days.

Regards,
Al

Member Avatar

If you don't find any joy from the php manual, show us your code and we'll be happy to help. If you want professional help - Google 'php coder hire'.

Hi,

Here's another option, try using cron jobs.

find /yourdir/tmp -mtime +1-exec rm {}

1 is the xx days.

Regards,
Al

Don't you need to close the statement after -exec ?

find /yourdir/tmp -mtime +1-exec rm {} \;

Oh yes, i forgot to close the statement. Thanks for the correction.

Regards

You want to delete all files from a folder, or want to delete files after x days from creation / last modified date?

You can go for "cronjob" for this task.hope you know about cronjob.

logic:
create one table in database.Where fields will be :
id, filePath, deleteDate, status

set cronjob task daily with one php file.
this php file will read table and delete file from filePath on deleteDate and update status.

hi ,

all i want to delete files after xx days from a folder using php

thnx in adv..

thanx for all help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.