Reputation: 671
I have a PHP script run from the command line like this: php test.php >> output.log. My output.log file has increased in size and I would like to implement some sort of rotation (archiving and truncating it when a certain condition is met). How can I do this, if I don't know the path to the file from within the code of the script, because it's set when it's called?
I see you can do it in Python as explained here: Is there a way to find out the name of the file stdout is redirected to in Python
Upvotes: 1
Views: 271
Reputation: 151720
You can't, at least not using >>
, because that way PHP does not know where its output goes.
You'd have to implement it in PHP itself.
Upvotes: 1