If I put in cron two tasks for execution at the same time, then how will they be executed (and executed): in parallel or alternately (the second will be executed after the first)?
1 answer
If tasks are described in crontab in different lines, they will be executed independently of each other, including in parallel, if the time coincides.
If you want the two tasks to be performed strictly one after the other, you can write them in one line, separated by a semicolon:
01 12 * * * mike task1 parameters; task2 parameters; ... In addition, if by the time of its next start the previous instance of the task has not yet completed, the cron will not check anything and will launch the second copy. Tracking a parallel launch and preventing it remains on the conscience of the task itself.
|
задача1 параметры && задача2 параметры. True in this case, task 2 will be executed after the successful implementation of the first. You can try, in principle, through a semicolon in one line, it seems to me that it should work that way. If the task does not complete the cron will run it a second time. Therefore, the task itself must control that there are no copies of it now (parimer is again a script that puts its PID in / var / run and checks if there is a file and a task with such a PID at startup) -