Como obter o comando linux shell script contendo quote trabalhando em crontab?

0

Eu vejo um problema, em que o comando / script do script de shell funciona bem quando executado por meio da linha de comando ou script de shell, mas falha quando acionado por meio do crontab. A seguir estão os detalhes do comando

Comando executado por meio do prompt de comando:

$ sbt "gatling:testOnly someTest"
Comando

contido no script de shell:

$ more runTest2.sh 
#!/usr/bin/env bash
set -x
cmdline='sbt "gatling:testOnly someTest"'
echo " commandToRun " $cmdline
eval ${cmdline}

Tanto a execução do script de shell quanto a execução da linha de comando direta funcionam bem

crontab -l
02 22 * * * /home/ranjesh_viswa/someproject/test/performance/runTest2.sh >> /home/someuser/someproject/test/performance/testLog.log  2>&1

Erro exibido ao executar o crontab:

+ cmdline='sbt "gatling:testOnly someTest"'
+ echo ' commandToRun ' sbt '"gatling:testOnly' 'someTest"'
 commandToRun  sbt "gatling:testOnly someTest"
+ eval sbt '"gatling:testOnly' 'someTest"'
++ sbt 'gatling:testOnly someTest'
[info] Loading project definition from /home/someuser/project
[info] Set current project to someuser (in build file:/home/someuser/)
[error] Expected key
[error] Expected '::'
[error] Expected end of input.
[error] No such setting/task
[error] gatling:testOnly someTest
[error]                 ^
    
por mohan 09.10.2018 / 12:31

0 respostas