rubing Posted May 31, 2008 Share Posted May 31, 2008 Is it possible to make a php file delete itself? I would like to do this since my script is a curl robot being running as a cron job, if its not getting the correct responses, I rather just terminate it. Link to comment https://forums.phpfreaks.com/topic/108083-self-destructing-php-script/ Share on other sites More sharing options...
dezkit Posted May 31, 2008 Share Posted May 31, 2008 yes Link to comment https://forums.phpfreaks.com/topic/108083-self-destructing-php-script/#findComment-554012 Share on other sites More sharing options...
rubing Posted May 31, 2008 Author Share Posted May 31, 2008 So, I should just execute the unlink function with path to itself? Link to comment https://forums.phpfreaks.com/topic/108083-self-destructing-php-script/#findComment-554013 Share on other sites More sharing options...
awpti Posted May 31, 2008 Share Posted May 31, 2008 Why not just have the script terminate itself (exit, die()) and write a file that tells it not to fully execute again? pseudocode FTW. (and yes, the backticks will work as long as the directory is writable by the user the cronjob runs as) <?php if(is_file('/path/to/where/the/php_script/is/do_not_execute') { exit; } // If it doesn't exit, then run the cronjob. // insert scripting here if(something_failed) { `touch /path/to/where/the/php_script/is/do_not_execute` } Link to comment https://forums.phpfreaks.com/topic/108083-self-destructing-php-script/#findComment-554047 Share on other sites More sharing options...
rubing Posted May 31, 2008 Author Share Posted May 31, 2008 God bless your vulcan logic! That would be even better...how clever. Link to comment https://forums.phpfreaks.com/topic/108083-self-destructing-php-script/#findComment-554449 Share on other sites More sharing options...
rubing Posted May 31, 2008 Author Share Posted May 31, 2008 hmmm... I can just call the php function touch($filename), from within my catch block. Link to comment https://forums.phpfreaks.com/topic/108083-self-destructing-php-script/#findComment-554453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.