How would you schedule a recurring Linux job so two runs do not overlap?
Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Saved automatically
Model Answer & Deep-Dive Explanation
Use an appropriate locking mechanism around the entire protected job, such as flock on a lock file in a directory accessible to the job’s user. Decide whether a second invocation should wait or exit and ensure the lock scope covers all relevant work. Use explicit paths, a controlled environment, reliable logging, and meaningful exit codes. A scheduler interval alone does not prevent overlap when a run lasts longer than expected. File locking on one host is not a distributed lock, and filesystem semantics must be suitable for the chosen mechanism.
Related Questions in Unix / Linux
Unix/Linux administration interview questions
Advanced level • 832 views
Linux admin interview questions
Intermediate level • 749 views
Nix Application Programming
Intermediate level • 706 views
Unix/Linux programming interview questions
Intermediate level • 575 views
Php and MySQL Important Questions
Advanced level • 511 views