[PLUG] Dumb script question

Richard C. Steffens rsteff at comcast.net
Mon Apr 19 03:01:15 UTC 2010


John Jason Jordan wrote:
> I have a desktop computer (Intrepid x86_64) that runs for months and
> months and is never rebooted. (All it does is play the radio and and the
> occasional movie, and act as a backup in case I seriously goober up my
> laptop.) I noticed this afternoon that its time was off by five
> minutes. I know that I can reset the time from an NTP server by
> rebooting, but that is a pain. Google told me that I can reset the time
> with:
>
> ntpdate 0.pool.ntp.org
> hwclock --systohc
>
> So I decided to use my amazing knowledge of bash scripting learned at
> the recent class to create a little script with an icon next to the
> clock display in the Gnome panel. My script is:
>
> #! /bin/bash
> su #'cause only root can set the time
> ntpdate 0.pool.ntp.org
> hwclock --systohc
>
> When I try to run it as jjj it asks for root password, I enter it,
> and then I get an authentication error. If I change to root first and
> then run it, it runs fine, and without prompting for root password.
>
> It must be the su line. How do I make a script run as root? Or can I
> fiddle with the permissions so jjj has permission to set the time, then
> just remove the su line from the script and forget about running it as
> root?
>   

Have you tried putting the su in front of ntpdate on the same line?

-- 
Regards,

Dick Steffens
 




More information about the PLUG mailing list