简体   繁体   中英

OS X Shell Script to run ntpdate

turns out I'm really bad at shell scripts...

I'm trying to make a script that will run;

ntpdate -u time.apple.com

So I created this script;

#!/bin/sh
ntpdate -u time.apple.com

I've chmod +X the script but it won't execute when I call

sudo ./timefix.sh

sudo: ./timefix.sh: command not found

If I just call ./timefix.sh I get;

-bash: ./timefix.sh: Permission denied

ntpdate requires sudo privileges to run.

My final goal is to package this up into an app with Automator so that it runs every boot. I have a handful of Macs in this office that are having internal clock issues. This is meant to be my dirty work around until I can get time to strip them back and replace the RTC batteries.

Can anyone help me fix my script please?

只需将+ X更改为小写+ x

chmod +x ./timefix.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM