Contrib: generate random crontab tmp path (#3068)

Co-authored-by: Dumazeau <hdumazeau@richcongress.com>
This commit is contained in:
hdumazeau 2022-08-28 18:50:55 +02:00 committed by GitHub
parent 6cec2890f4
commit e374a8e2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,17 +91,19 @@ task('crontab:sync', function () {
}
}
if (test ("[ -f '/tmp/crontab_save' ]")) {
run ("unlink '/tmp/crontab_save'");
$tmpCrontabPath = \sprintf('/tmp/%s', \uniqid('crontab_save_'));
if (test("[ -f '$tmpCrontabPath' ]")) {
run("unlink '$tmpCrontabPath'");
}
foreach ($cronJobs as $cronJob) {
$jobString = $cronJob['minute'] . ' ' . $cronJob['hour'] . ' ' . $cronJob['day'] . ' ' . $cronJob['month'] . ' ' . $cronJob['weekday'] . ' ' . $cronJob['cmd'];
run ("echo '" . $jobString . "' >> '/tmp/crontab_save'");
run("echo '" . $jobString . "' >> $tmpCrontabPath");
}
run ("{{bin/crontab}} /tmp/crontab_save");
run ('unlink /tmp/crontab_save');
run('{{bin/crontab}} ' . $tmpCrontabPath);
run('unlink ' . $tmpCrontabPath);
});