Run a command with sudo in bash shell


How can i run a command in shell script with sudo? This script will be run by a cron job, so there should be no human intervention to enter a password manually.

Best Solution

Enter the cronjob in

sudo crontab -e 

then the whole script will be executed as root per default without the need of a password.