[clug-talk] Setting Time Programatically without being root
jason.k.louie at gmail.com
Tue Nov 30 15:37:12 PST 2004
If you want a script that would keep your system up to date with the
current date and time I have one I can post.
# $Id: sync-clock,v 1.5 2003/02/04 20:23:39 jmates Exp $
# Use ntpdate to get rough clock sync with department of Genome Sciences
# time server.
echo -n "Start -- " >> $LOGFILE
date >> $LOGFILE
# if running from cron (no tty available), sleep a bit to space
# out update requests to avoid slamming a server at a particular time
if ! test -t 0; then
if [ $MYRAND -gt 9 ]; then
sleep `echo $MYRAND | sed 's/.*\(..\)$/\1/' | sed 's/^0//'`
$NTPDATE -su $SERVER
# update hardware clock on Linux (RedHat?) systems
if [ -f /sbin/hwclock ]; then
echo -n "Done -- " >> $LOGFILE
date >> $LOGFILE
Put this in your /etc/cron.daily/ or /etc/cron.hourly/ and your clock
should sync with the UofC server.
On Tue, 30 Nov 2004 16:22:45 -0700, Adil Kodian <akodian at gmail.com> wrote:
> On Tue, 30 Nov 2004 15:52:16 -0700, Evan Brown <evan at totaltrucking.com> wrote:
> > Hi
> > Is there a way to change the time on the system from a C program without
> > being logged in as root?
> > Evan Brown
> umm... no - because changing system parameters like time is a root
> process. However, the user can probably change timezones in the X
> window environment without affecting system clock.
> if you want to custom design your linux box - of course you can do it
> in a c program - its open source :-)
> clug-talk mailing list
> clug-talk at clug.ca
> Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
> **Please remove these lines when replying
More information about the clug-talk