You will need to find out if your host allows you to do cron jobs
first.
Assuming you can...
This is how I did it, but it doesn't mean its the correct way. I'm
using Cakephp 1.3.0
inside your app/webroot folder, duplicate your "index.php" and name it
something so you know its for cron jobs.
at line 78 and an else to the above if statement i.e.this one: if (!
include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
else {
define('CRON_JOB', true);
if($argc == 2){
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch($argv[1]);
}
}
create a layout for the cron job that only outputs content, there
should be no javascript or css. I kept the flash messages so if
something goes wrong cron notifies my via email.
Write a method(function) in your controller that takes care of
deleting your temp folder.
You will also need a view that only outputs what you want to see.
i.e. I only ouput a successful message when stuff is deleted. If
nothing happens I don't want to know about it.
Then on your host's control panel or however you have access to cron
you can set up your script to run every second, minute, hour, month,
or year.
On my host as most shared hosting hosts, you have to tell php to run
your script, this is what my cron job looks like.
0 3 * * * php -q /path/to/public_html/app/webroot/cron_job.php /events/
expire
so my script runs every day at 3am
On Aug 9, 2:27 am, Tomfox Wiranata <[email protected]> wrote:
> thx miles for the reply...
>
> is there sth specific in cake to do this?
>
> On 6 Aug., 20:35, Miles J <[email protected]> wrote:
>
> > Just setup a cron job that runs every 1/24 hour(s) that cleans up the
> > tmp directory.
>
> > Why not just put all uploads into the same tmp directory? Very slim
> > chance anything will ever overwrite each other.
>
> > On Aug 6, 6:03 am, Tomfox Wiranata <[email protected]> wrote:
>
> > > hi,
>
> > > lets say a user uploads an image. then i create a temp-folder to save
> > > it temporarily. once the user is finished i delete this temp directory
> > > and copy the image to the actual path.
>
> > > now lets say, he uploads it, cake puts it to the temp directory and
> > > the user cancels the process by shutting down the browser or just
> > > leaving the website. if that happens, i want to delete the temp-dir.
> > > so is it possible to check if the user left the site or shut down the
> > > browser?
>
> > > if not, then i'd like to check what temp directories have been created
> > > 24hrs ago and still exist, so i can delete them. is that possible?
>
> > > thank you so far. as usual :)
>
> > > btw: i love this forum
>
>
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en