Isso pode ser replicado por
sh -c 'pkill -f "MyExecutable.exe" ; touch /tmp/here.log'
Cron executa seu comando passando-o para um shell ( sh ou outro), então é muito semelhante à linha acima. Independentemente de haver MyExecutable.exe em execução ou não, pkill -f corresponde (também) ao shell e o mata antes de executar touch . Isso é porque
The pattern is normally only matched against the process name. When
-fis set, the full command line is used.
(fonte: man 1 pkill )
Soluções possíveis:
-
Se você não precisa de
-f, basta soltá-lo:42 17 * * 1-5 /bin/pkill 'MyExecutable.exe' ; touch /tmp/here.log -
Se você precisar de
-f, executetouchantes depkill:42 17 * * 1-5 touch /tmp/here.log ; /bin/pkill -f 'MyExecutable.exe'