Open soc8ren opened 1 year ago
I think you could try to call unlink
in Closure passed to \Crunz\Event::after
.
I think you could try to call
unlink
in Closure passed to\Crunz\Event::after
.
Thanks for this. But, upon rechecking, I had totally forgotten about the pre and post-hooks functionality. I will also have to try if after on schedule would work. WiIll report back.
First, thanks for this awesome library. I am using it for learning purposes. I have a few tasks in my tasks directory, all of which are php files running with the PHP BINARY by Crunz. I was wondering if there is a way to delete the php file after its execution.
Things that I have tried to achieve this:-
UNLINK(__FILE__);
to the task php. But, I can't have it beforereturn $schedule
as the script won't complete and the task file gets deleted. I can't have it afterwards either, as anything afterreturn $schedule
doesn't run.$schedule->run(PHP_BINARY . -r 'UNLINK(__FILE__');
But,__FILE__
here returns a value ofCommand line code
and I tried various versions of it, but none of them work.I am trying to self destroy the task once it has been executed from within the task php file itself. I am aware of using sh or bash to do this. But, I would really love to know if there was a way to achieve this from within the PHP file itself.