I need to manually create a directory using the following command in a cronjob and not have to enter in a password:
sudo mkdir /fold1/
I have read that I should not edit /etc/sudoers directly.
What are my options?
Add the script to root's cronjob:
sudo crontab -e
You need to be a sudoer to run the above command. You also will still have to cd to the correct directory inside your script to create your new directory in the right location.
sudoinside the cron job? Does your system not support running cron jobs as other users (via/etc/crontab, orsudo crontab -efor example)?visudocommand to edit /etc/sudoers". Please checkman visudo.