I have a set of update commands that I need to run periodically as per compliance with my university's policies on security. These are the commands :
sudo apt-get clean
sudo apt-get update
sudo apt-get -y --purge dist-upgrade
Now what I want to do is to automate this process. The way I would go about this is to
- Set up all these commands as a shell script.
- Run the script as a cronjob everyday at 6AM in the morning.
I wrote a shell script named "update_script.sh" and saved it in the home folder. Inside the script was the three commands without the sudo option. Then I changed the ownership of the script to root.
Next I modified the visudo file to allow this script to run without a password.
(I followed the steps in this link)
Now my problem is this :
When I am trying to run this update script as "sh update_script.sh" it cannot run it. Only when I do "sudo sh update_script.sh" it does the job.
Where did I mess up in the setup ?