gpt4 book ai didi

linux - ntpd sync 后执行脚本

转载 作者:太空狗 更新时间:2023-10-29 11:04:16 24 4
gpt4 key购买 nike

我有 raspberry pi 和 raspbian。我想在时间与 ntpd 同步后立即执行脚本,我的脚本需要正确的日期时间。我该怎么做?

最佳答案

正确的方法是使用ntp-waitntp-wait 就是为这种情况量身定做的。这是手册页:

ntp-wait(1)                     User Commands                    ntp-wait(1)

NAME
ntp-wait - Wait for ntpd to stabilize the system clock

SYNOPSIS
ntp-wait [-flag [value]]... [--opt-name [[=| ]value]]...

All arguments must be options.

DESCRIPTION
will send at most num-tries queries to sleeping for secs-between-
tries after each status return that says has not yet produced a syn‐
chronized and stable system clock.

will do this quietly, unless the v flag is provided.

OPTIONS
-n num-tries, --=num-tries
Number of times to check ntpd. This option takes an integer
number as its argument. The default num-tries for this option
is:
100

The maximum number of times we will check ntpd to see if it
has been able to synchronize and stabilize the system clock.

-s secs-between-tries, --=secs-between-tries
How long to sleep between tries. This option takes an integer
number as its argument. The default secs-between-tries for
this option is:
6

We will sleep for @file{secs-between-tries} after each query
of ntpd that returns "the time is not yet stable".

-v, -- Be verbose.

By default, ntp-wait is silent. With this option, ntp-wait
will provide status information.

-?, --help
Display usage information and exit.

-!, --more-help
Pass the extended usage information through a pager.

- [{v|c|n}], --version[={v|c|n}]
Output version of program and exit. The default mode is `v',
a simple version. The `c' mode will print copyright informa‐
tion and `n' will print the full copyright notice.


EXIT STATUS
One of the following exit values will be returned:

0 Successful program execution.

1 The operation failed or the command syntax was not valid.

关于linux - ntpd sync 后执行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28079968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com