000-221 · Question #27
A user wants to run a batch job repetitively, but requires that each invocation starts five hours after the previous run finishes. What strategy will accomplish this?
The correct answer is D. Create a file containing the job commands, using the 'at' command as the final line of the file. The 'at' command can schedule a one-time job, and by placing another 'at' invocation as the final command in the job file, the job reschedules itself to run again after completing, ensuring the five-hour gap starts after the previous run finishes.
Question
A user wants to run a batch job repetitively, but requires that each invocation starts five hours after the previous run finishes. What strategy will accomplish this?
Options
- ACreate a wrapper script that launches the job in the background and then sleeps for the designated
- BSubmit the job with 'at', using the average run time of the job plus five hours as the interval.
- CAdd an entry to the crontab to submit the job every five hours.
- DCreate a file containing the job commands, using the 'at' command as the final line of the file.
How the community answered
(21 responses)- A5% (1)
- B10% (2)
- C14% (3)
- D71% (15)
Why each option
The 'at' command can schedule a one-time job, and by placing another 'at' invocation as the final command in the job file, the job reschedules itself to run again after completing, ensuring the five-hour gap starts after the previous run finishes.
A background launch with sleep would start the timer immediately when the job is launched, not after it finishes, so the five-hour gap would not reliably follow job completion.
Using 'at' with a fixed average-time interval is unreliable because actual run times vary, meaning the next job could start before or too long after the previous one completes.
Cron schedules jobs at fixed calendar intervals regardless of whether a previous instance has finished, so it cannot enforce a delay that begins only after a job completes.
By placing an 'at' command as the last line of the job script, the job schedules its next execution only after it has fully completed. This guarantees a five-hour delay from job completion rather than from job start, satisfying the requirement that each invocation starts five hours after the previous run finishes.
Concept tested: Scheduling self-rescheduling jobs using 'at' command
Source: https://man7.org/linux/man-pages/man1/at.1.html
Topics
Community Discussion
No community discussion yet for this question.