How would cron handle a job that executes multiple commands.
As an example I have a cron job that looks like this. Which gets very difficult to read.
10 0 * * * firstscript.sh > first.log; secondscript.sh >> second.log; thirdscript.sh >> third.log 2>&1;
All three scripts execute at the same time. In my environment we have 6 commands executed in sequence.
Why not write that same jobs three separate jobs.
10 0 * * * firstscript.sh > first.log; 10 0 * * * secondscript.sh >> second.log; 10 0 * * * thirdscript.sh >> third.log 2>&1;
I inherited these jobs and am trying to get a better understand of why do it as multiple commands in stead of 3 separate jobs.
The first reason I can think of that there may be dependencies between the scripts. So they have to run in that specific order. So
The second reason is that these scripts/commands are expensive to execute and the server runs better when they run sequentially. Potential file locks and multiple commands writing to the same file could also cause issues.
If the first script exits with error, do the commands following it run?
If dependencies are an issues, is there way to split the job into multiple jobs and still satisfy the dependencies?
Does cron have a facility like that?