You are right, when i access the second script directly from a browser then it execute for 300 seconds and no issue at all.
The issue only when the second URL triggered by first script.
Please let me know if you want me to share the original URLs to the scripts.