How to locked child Y rotation?

i want a child to follow parent but ignore Y rotation change.

I think something like this:

    Vector3 startRot;

    void Start () {
       Vector3 startRot =  transform.rotation.eulerAngles;      
    }

    private void Update()
    {
        transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.x, startRot.y,transform.rotation.z));
    }

Sorry, I try, but it don’t work for my case. And I find out what I really need is:
A-B-C
B is child of A, C is child of B.
A don’t move, but B move and rotate
And I want C always stay at A transform.forward direction, while following B position and rotation.

Then you want basically the same thing, but instead of using the start rotation, you use the grandparent.

transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.x, A.rotation.transform.eulerAngles.y,transform.rotation.z));

Otherwise maybe try :

transform.rotation = A.transform.rotation;