I\'m using Spring Boot and I\'ve got a use case where user can upload a file which should cause a restart of application (since user\'s upload is used during creation of mul
I have a special case in which my Spring Boot application, which runs on Linux, is required to run as root.
Since I run the application as systemd service, I can restart it like this:
Runtime.getRuntime().exec(new String[] { "/bin/systemctl", "restart", "foo" });
If your application is (hopefully) not required to run as root, a setuid wrapper-script could be used, or better, use sudo.
Check this answer on how to do that:
https://superuser.com/questions/440363/can-i-make-a-script-always-execute-as-root