I want to start the w
command periodically, according to man watch
the smallest possible time interval is 0.1.
I tried:
watch -n1 w (works)
watch -n1.5 w (does not work)
watch -n0.1 w (does not work)
When I try to start the watch
command with the n-option as non-integer, I get the error message:
watch: failed to parse argument: '0.1'
Best Answer
This is a locale problem.
watch
usesstrtod(3)
, which is locale-dependent, to convert the argument to-n
to adouble
.To fix the problem, you need to either specify the argument to
-n
with a different separator:Or change your locale to a setting where the period character is used for the decimal point:
A couple of references:
strtod
:You can review your current settings by running
locale
in your terminal:The source code in question can be reviewed at gitlab:
https://gitlab.com/procps-ng/procps/blob/85fff468fa263cdd2ff1c0144579527c32333695/watch.c#L625
https://gitlab.com/procps-ng/procps/blob/85fff468fa263cdd2ff1c0144579527c32333695/lib/strutils.c#L49
(edit 2017-09-07): updated gitlab links