Can't use '&&' in commands
FarisZR opened this issue · 2 comments
FarisZR commented
Hey, first thanks for the awesome project!
I was testing this locally, and I think I hit some kind of bug or regression, as i can't seem to be able to use &&
correctly in the command
argument.
It always seems to be just taken as an argument for the first command.
Example
services:
ofelia:
image: mcuadros/ofelia:latest
command: daemon --docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
ofelia.job-local.create_guest_accounts.schedule: "@every 5s"
ofelia.job-local.create_guest_accounts.command: 'date'
Output
testing-ofelia-1 | 2023-12-27T16:38:49.279Z scheduler.go:34 ▶ NOTICE New job registered "create_guest_accounts" - "date" - "@every 5s"
testing-ofelia-1 | 2023-12-27T16:38:49.279Z scheduler.go:54 ▶ DEBUG Starting scheduler with 1 jobs
testing-ofelia-1 | 2023-12-27T16:38:54.002Z common.go:125 ▶ NOTICE [Job "create_guest_accounts" (1e06e51dde73)] Started - date
testing-ofelia-1 | 2023-12-27T16:38:54.009Z common.go:125 ▶ NOTICE [Job "create_guest_accounts" (1e06e51dde73)] StdOut: Wed Dec 27 16:38:54 UTC 2023
testing-ofelia-1 | 2023-12-27T16:38:54.009Z common.go:125 ▶ NOTICE [Job "create_guest_accounts" (1e06e51dde73)] Finished in "6.903339ms", failed: false, skipped: false, error: none
Example with &&
services:
ofelia:
image: mcuadros/ofelia:latest
command: daemon --docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
# - ./config.ini:/src/config.ini
labels:
ofelia.job-local.create_guest_accounts.schedule: "@every 5s"
ofelia.job-local.create_guest_accounts.command: 'date && echo "test"'
Output
testing-ofelia-1 | 2023-12-27T16:46:54.017Z scheduler.go:34 ▶ NOTICE New job registered "create_guest_accounts" - "date && echo \"test\"" - "@every 5s"
testing-ofelia-1 | 2023-12-27T16:46:54.017Z scheduler.go:54 ▶ DEBUG Starting scheduler with 1 jobs
testing-ofelia-1 | 2023-12-27T16:46:59.002Z common.go:125 ▶ NOTICE [Job "create_guest_accounts" (5d74226e6d2f)] Started - date && echo "test"
testing-ofelia-1 | 2023-12-27T16:46:59.014Z common.go:121 ▶ ERROR [Job "create_guest_accounts" (5d74226e6d2f)] StdErr: BusyBox v1.35.0 (2022-11-19 10:13:10 UTC) multi-call binary.
testing-ofelia-1 |
testing-ofelia-1 | Usage: date [OPTIONS] [+FMT] [[-s] TIME]
testing-ofelia-1 |
testing-ofelia-1 | Display time (using +FMT), or set time
testing-ofelia-1 |
testing-ofelia-1 | -u Work in UTC (don't convert to local time)
testing-ofelia-1 | [-s] TIME Set time to TIME
testing-ofelia-1 | -d TIME Display TIME, not 'now'
testing-ofelia-1 | -D FMT FMT (strptime format) for -s/-d TIME conversion
testing-ofelia-1 | -r FILE Display last modification time of FILE
testing-ofelia-1 | -R Output RFC-2822 date
testing-ofelia-1 | -I[SPEC] Output ISO-8601 date
testing-ofelia-1 | SPEC=date (default), hours, minutes, seconds or ns
testing-ofelia-1 |
testing-ofelia-1 | Recognized TIME formats:
testing-ofelia-1 | @seconds_since_1970
testing-ofelia-1 | hh:mm[:ss]
testing-ofelia-1 | [YYYY.]MM.DD-hh:mm[:ss]
testing-ofelia-1 | YYYY-MM-DD hh:mm[:ss]
testing-ofelia-1 | [[[[[YY]YY]MM]DD]hh]mm[.ss]
testing-ofelia-1 | 'date TIME' form accepts MMDDhhmm[[YY]YY][.ss] instead
testing-ofelia-1 | 2023-12-27T16:46:59.014Z common.go:121 ▶ ERROR [Job "create_guest_accounts" (5d74226e6d2f)] Finished in "11.820866ms", failed: true, skipped: false, error: exit status 1
taraspos commented
To use &&
you will need to create a shell.
Could you try your example with:
'/bin/sh -c "date && echo test"'
FarisZR commented
Yup that fixed it! I think it should be documented somewhere though, maybe as an example?