Running two commands in crontab
By Emily Wilson •
I have this line in my crontab file
*/1 * * * * espeak 'foo' && espeak 'bar'But only half of it, first command gets executed every minute.
While when I write this in the terminal it works like a charm.
Is there a different way to execute 2 commands in the same line in the crontab file ?
12 Answers
&& is interpreted by bash as one of the operators that separate pipelines in a command line. If you call those commands from bash both should run:
*/1 * * * * bash -c 'espeak "foo" && espeak "bar"' 2 Using && in crontab is correct.
If the second command is not executed, it means that the first command does not return successfully. You may then want to use espeak 'foo'; espeak 'bar' (so the second command is executed whatever the first one returns), but that does not tell you why the first command does not return successfully.