0

I'm trying to monitor a file that will get downloaded by another process using ls -haltd. When I run the watch command the execution fails.

e.g.

$ watch ls -halt myfile.txt
-bash: /usr/bin/watch: cannot execute binary file: Exec format error

I've checked to make sure there are no aliases for watch (there are no aliases for anything)

I've checked the binary with file

$ file `which watch`
/usr/bin/watch: ELF 64-bit (SYSV)

and I've verified my OS as

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
$ uname -a
Linux valhalla 5.4.0-1053-raspi #60-Ubuntu SMP PREEMPT Fri Feb 11 07:18:29 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

The machine is built of the same image as many others and I'm not having this issue elsewhere. Before I go off modifying the config of a production server, any thoughts on the cause of this?

6
  • try watch 'ls -halt myfile.txt' ... ie. pass the ls -halt myfile.txt as a single parameter instead of as multiple parameters ; ie. your command caused -halt and myfile.txt to not be part of the ls command you gave as a parameter but get treated as extra operands of watch...
    – guiverc
    Mar 17, 2022 at 5:10
  • Is ELF 64-bit (SYSV) the complete output of the file command? does it not mention an interpreter at all? Mar 17, 2022 at 11:24
  • Just tried single quoting it, no joy using single or double quotes; $ watch 'ls -halt myfile.txt' -bash: /usr/bin/watch: cannot execute binary file: Exec format error Mar 18, 2022 at 6:15
  • yes @steeldriver that is the entire output. On a different (PopOS) box it reports as a ELF 64-bit LSB pie executable. AFIK the watch command is an executable in all cases (not a script) Mar 18, 2022 at 6:17
  • A bit of source code spelunking reveals that the watch command will consume everything after the last option as the command, no quotes necessary; gitlab.com/procps-ng/procps/-/blob/newlib/watch.c#L879 Mar 18, 2022 at 6:42

0

You must log in to answer this question.

Browse other questions tagged .