I have a script which renice all instances of srcds on the server. This script requires to be executed as sudo or root.
I want this script to be executed automatically (cronjob fx).
But when I target the script in cronjob, it doesnt execute, and I cannot figure out why. I set it up with the same command as for anything else.
The script is located in /home/srcds/renice.sh
I tried multiple things fx the cronjob on root user
30 * * * * cd /home/srcds && sh renice.sh
I also tried to put it in non root users crontab with the command
30 * * * * root cd /home/srcds && sh renice.sh
30 * * * * sudo cd /home/srcds && sh renice.sh
The script simply wont execute this way. If I execute it as sudo with sudo ./renice.sh, then it works as intended. And if I do sudo su root, and execute it on root user, it also works, even though srcds instances are executed from a non sudo user.
I really want to renice via this script. But if it cant be done, what do you guys use to renice srcds?
*** EDIT ***
Server is running Ubuntu 18.04