ofelia
ofelia copied to clipboard
job-exec cannot execute multiple shells
[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.
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\"
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.