Is there a way to set up cron job to be ran at intervals of one hour and one minute? E. g. 12:00, 13:01, 14:02, 15:03 and so on indefinitely. When it gets again at 12 hours it should execute job at 12:24, the next at 13:25.
feedback
|
|
Try the at command.
commands.list: doupdate.sh at +61m < commands.list Of course, you want to use the full path for your files. Each time this runs, it will set up the next job 61 minutes in the future. You can run "atq" to view what is currently queued up. | |||
feedback
|
|
Check out fcron which is available with most distros and is more suitable for this kind of task. | |||||||
feedback
|
|
Cron is going to be the wrong tool for this. The problem with cron is that it doesn't keep state between job executions. It notoriously doesn't know if a job has run successfully before, if a job is still running before the next execution, etc. You should not rely on cron if you're trying to finesse the timing like this. A better option would be to investigate the task scheduling tools available in the language you're using. You basically need a process that knows the state of the previous run of the task, particularly the time of the last successful execution. Yes, this will result in an additional daemon running in the background, but this will likely be easier to maintain that some hacky way to implement the same thing in cron. | |||
|
feedback
|
|
Cron isn't going to entirely solve your problem here; you're going to have to maintain some external state to track the last time your job ran. One way to do this is as @cjc has suggested - run an extra daemon that handles the scheduling itself. Another way would be to have your job record the time it ran; and each time Cron fires it, refuse to start if the last run was too recent. This could be as simple as touching a file called "lastrun" at the end of each successful execution, then checking the timestamp on that file at the start of your next execution. You can then set the cronjob to fire every few minutes; on most occasions, it will notice the time difference is too small and exit immediately. | |||
|
feedback
|