as grub does not accept the password in single linewith below method.
[root@host1~]# echo -e “password\npassword” | grub2-setpassword
stty: standard input: Inappropriate ioctl for device
we can use below command to reset the grub password(but it ask for manual intervention)
printf '%s\n' "password" "password" | script -qf -c 'grub2-setpassword' /dev/null
save the above command to grub-pass.sh and run with nohup command