blackbird sr71 wrote:
> I am running opensuse 12.1. i synchronize my time from the command line
> using the following command:
>
>
> Code:
> --------------------
> ntpdate pool.ntp.org
> --------------------
>
>
> however, to run this command i need to be logged in as superuser.
>
> how can i write a bash script that can login as root and run this
> command. (i want to set this script to run as a cron task, hence…)
You don’t need a bash script to run a command as root. Just put the
command in root’s crontab.
But in this case, why don’t you simply use the ntp daemon? Use YaST to
set it up.
Why not using ntpd rather than ntpdate? Just enable this service, for example using Yast -> System Services -> ntp and “Yes”.
If you want to use ntpdate, you have to put it in a cron job (not in a bash script).