I have been trying to initialize a cron job programmatically with the help of JCrontab in Java. I have a cron file which i have given as the datasource to the job. At the start of my application, the Cron tab is up and running successfully. Let’s say at some point of time because of an unexpected failure in my application, the cron file becomes empty. But before the next cycle of the job, the file gets filled with cron entries again. But i dont restart the crontab programmatically again. The job fails to continue in the next schedule. Why doesn’t it get initialized automatically after watching the cron file get updated with the right data again? How does crontab handle updating cron files?


man cron:

There are two ways how changes in crontables are checked. The first method is checking the modtime of a file. The second method is using the inotify support. Using of inotify is logged in the /var/log/cron log after the daemon is started. The inotify support checks for changes in all crontables and accesses the hard disk only when a change is detected.

So the only possible reason for ignoring changes seems to be that the file's mtime is set back.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.