my system: Debian 11 Tomcat 9
Question: Is there a way to restart Tomcat Server with the crontab of user tomcat without providing tomcat's password?
My fails: To restart the Tomcat Server i need to use "sudo" for the tomcat user. To skip the password request i have "NOPASSWD" in the sudoers file for tomcat user but when i trigger my script with crontab of tomcat user i get following error: "Failed to restart tomcat9.service: Interactive authentication required. See system logs and 'systemctl status tomcat9.service' for details."
Here is my simple script:
#!/bin/bash
sudo /usr/sbin/service tomcat9 restart
when i skip the "sudo" in my script and use root's crontab my script runs perfectly fine. Due to security reasons and for my personal understanding, however, i would like to know how to make this work with tomcat's crontab.
Best regards.