Locking out user from sudo commands without rebooting

A more in depth explaination would be found here.

The use case of what I’m trying to do is:

  • You login to your desktop Linux computer.
  • You start a script and as input you give to it a time in the future, like 2 hours from now.
  • Then the script makes so that you are not able to execute any sudo command for the next 2 hours.
  • When 2 hours are passed you gain back admin privileges.

What I did was removing the user to sudo-group and then schedule it’s a command with at that would put the user back to sudo-group.
While this approach works perfectly, it is required to reboot everytime the user is removed or added from sudo group.

I’m asking if there’s an alternative path that would achieve the same result but without rebooting.