Got a cron to run everyday under my user. this cronjob runs a script from my /home/jack/scripts/run.sh Code: clear # # su to root and run a script, return with result # su - # passwd # run /getfile.sh # return with result # the result will copy 2 files from /prod/app/logs/ and throws to my /home/jack/scripts/file1.txt and file2.txt # awk -F" " '$5==0 && $3=="ServerA"{print $1}' file1.txt file2.txt | sort -r | head -1 > output.txt uuencode output.txt output.txt | mailx -s "Todays Server ErrorLog Reprot" [email protected] I am having the root password. Need to know how to su from normal user, run script which has root privileges, logout from user with result to my user and continue the next sequence of my script. All the above steps inside # remark statements needs proper code. Thanks in advance
Have a look at the sudo command instead of su and the sudoers file. It allows you to execute a program or script under different priveliges.