I read about the following 2 ways to run multiple commands in a single cron job:
We can run several commands in the same cron job by separating them with a semi-colon (;).
* * * * * /path/to/command-1; /path/to/command-2
If the running commands depend on each other, we can use double ampersand (&&) between them. As a result, the second command will not be executed if the first one fails.
* * * * * /path/to/command-1 && /path/to/command-2
My requirements are:
- the commands must be executed sequentially (wait for the current one to complete before executing the next one)
- the commands must be executed in the given order
- but every command should be executed, even if the previous one failed
What the link above therefore doesn't say is:
Does the semicolon ;
approach still guarantees that the commands will be executed sequentially, and in the given order?
date +%Y%m%d
in crontab. Hint: % has special meaning. – meolic Nov 26 '20 at 18:31