1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. Maybe the Python link gives someone else a clue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.