ofelia icon indicating copy to clipboard operation
ofelia copied to clipboard

job-exec cannot execute multiple shells

Open wenshunbiao opened this issue 5 years ago • 2 comments

[job-exec "test"]
schedule = @every 10m
container = container 
command = cd /home && touch test.txt

or

[job-exec "test"]
schedule = @every 10m
container = container 
command = sh -c "cd /home && touch test.txt"

Failed to achieve the expected effect. How can I execute multiple shell? In addition to writing shell scripts.

wenshunbiao avatar Nov 22 '19 10:11 wenshunbiao

With some experimentation, I've found that you have to escape the quotes, like this:

command = sh -c \"cd /home && touch test.txt\"

however, sometimes you want to use the ; (useful if you want to execute the second command even if the first fails). I found no way to use it since the ini format treats it like a comment. But something like this works as a workaround:

command = sh -c \"command1 || true && command2\"

damir00 avatar Dec 04 '19 15:12 damir00

Me too experimented and i found the best form is that: [job-exec "test-1"] schedule = @every 5m container = container command = cd /home

[job-exec "test-2"] schedule = @every 10m container = container command = touch test.txt

And work fine.

mitosu avatar Feb 04 '21 13:02 mitosu