简体   繁体   English

OS X Shell脚本运行ntpdate

[英]OS X Shell Script to run ntpdate

turns out I'm really bad at shell scripts... 结果我在shell脚本上真的很糟糕......

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 我已经chmod + X脚本,但是当我打电话时它不会执行

sudo ./timefix.sh

sudo: ./timefix.sh: command not found

If I just call ./timefix.sh I get; 如果我只是打电话给./timefix.sh我得到;

-bash: ./timefix.sh: Permission denied

ntpdate requires sudo privileges to run. ntpdate需要sudo权限才能运行。

My final goal is to package this up into an app with Automator so that it runs every boot. 我的最终目标是将其打包到Automator的应用程序中,以便它在每次启动时运行。 I have a handful of Macs in this office that are having internal clock issues. 我办公室里有一些Mac有内部时钟问题。 This is meant to be my dirty work around until I can get time to strip them back and replace the RTC batteries. 这是我的肮脏工作,直到我有时间去除它们并更换RTC电池。

Can anyone help me fix my script please? 任何人都可以帮我修复我的脚本吗?

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

chmod +x ./timefix.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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