0

I work for a non-profit and recently had to take on some sysadmin responsibilities, and and it is a new area for me.

We have a Apple X Server that is running Darwin, and from time to time, especially on reboots, the timer on it gets out of sync which causes the machine to be unaccessible via share. I would like to write a little script that i can run that logs-in, updates the time, and logs out.

The main reason I would like to do it this way, is so that I can share that script user/pw with other non-technical folk. Currently, I login as root "Administrator" and type the following, "date MMddHHmmYY" (substituting the values MMddHHmmYY with the current date/time) and the problem resolves the issue.

I have read that only the root can change the date on the box, is it possible to create a user who logs in as root, changes time, logs out, without giving the root user info away?

I have not written a script before, and don't really know where to start. If you can point me in the right places, I would be very grateful.

Hennes
  • 65,804
  • 7
  • 115
  • 169

1 Answers1

0

You do not need to write a script for this. The following command will do the job:

   ssh root@AppleXServer 'date MMddHHmmYY'

This command, issued from any pc capable of reaching AppleXServer, executes the command within apostrophes as the user who is logging into the machine, in this case root.

However, for this to work you must have root credentials, there is no way around that.

MariusMatutiae
  • 48,517
  • 12
  • 86
  • 136