[PLUG] Dumb script question

wes plug at the-wes.com
Mon Apr 19 03:16:46 UTC 2010


how do you "change to root" ? I'm betting it's with sudo su rather than just
su. When you use sudo, it asks for jjj's password instead of root's.

There are 2 solutions available: change your script to use sudo in front, or
just have the commands run as root automatically on a schedule via cron.

-wes

On Sun, Apr 18, 2010 at 7:55 PM, John Jason Jordan <johnxj at comcast.net>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?
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



More information about the PLUG mailing list