crunz
crunz copied to clipboard
Any way to delete a php script task file after its execution
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:-
- Tried adding
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. - I also tried running the scheduler to delete the file
$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.