Remove old kernel batch ..

it is a valid programs ?
It appears to be unmaintained/depreciated since Nov 2023. Also looking at the issues section tells a similar story.

As you are probably aware, you should not use any scripts blindly from the internet - if you have not reviewed their code properly & fully understand what they attempt to do.

Having said that, I have reviewed this one & use it frequently. Here is the actual code.
 
apt autoremove --purge
That will remove & purge ALL packages automatically installed and not anymore required by any other package, (including system wide configuration files). Not just kernels exclusively. Also AFAIK if you manually added/installed a kernel - this command will not remove it.

Also this command does not give the user control over which kernels will actually be removed - and AFAIK will leave the current kernel + one before.

Also this command will not update the Grub config to reflect the remaining kernels available. You would have to subsequently add the update-grub command to do that.

Script above takes care of all the above.
 
That will remove & purge ALL packages automatically installed and not anymore required by any other package, (including system wide configuration files). Not just kernels exclusively. Also AFAIK if you manually added/installed a kernel - this command will not remove it.
Good point. I run it indeed to remove old packages that are no longer used, kernel or otherwise.
Also this command does not give the user control over which kernels will actually be removed - and AFAIK will leave the current kernel + one before.
As you mentioned: kernels I installed explicitly are kept and others are removed. Usually what I want but maybe not what the OP wanted, I see now.
Also this command will not update the Grub config to reflect the remaining kernels available. You would have to subsequently add the update-grub command to do that.
Actually, it does update my ESPs with systemd-boot (ZFS in UEFI mode without SecureBoot) using proxmox-boot-tool and I do not have to update anything manually afterwards.
Script above takes care of all the above.
Thank you for pointing out how my approach is not specific to kernels. I did not think about that as it works for the purpose of clean up in my case.
 
It appears to be unmaintained/depreciated since Nov 2023. Also looking at the issues section tells a similar story.

As you are probably aware, you should not use any scripts blindly from the internet - if you have not reviewed their code properly & fully understand what they attempt to do.

Having said that, I have reviewed this one & use it frequently. Here is the actual code.
thank you very much
 
When you run update-grub it will run but you will get this warning
Generating grub configuration file ...
W: This system is booted via proxmox-boot-tool:
W: Executing 'update-grub' directly does not update the correct configs!
W: Running: 'proxmox-boot-tool refresh

So you should probably run proxmox-boot-tool refresh instead of update-grub