Score:0

How to sync crontab with fcrontab, i.e. timer-based job and time-based job

cn flag
Jay

Having 2 schedules set:

  1. Cron running every 8am 0 8 * * * myCronJob.sh
  2. Fcron running every 61 minutes: @1h1 myFcronJob.sh

They will eventually bump into each other and it will not work because in this scenario only one job can run at a time. To avoid this issue we might use a lock to allow only one job at a time, such as this code here

0 8 * * * user/bin/flock /usr/tmp/lfile.lockfile -c 'myCronJob.sh'

@ 1h1 user/bin/flock /usr/tmp/lfile.lockfile -c 'myFcronJob.sh'

This rises another issue, if fcron is configured to run every 61 minutes and when it starts and will wait for the other job to finish, the timer will be misaligned because the next time it runs, will be

(61 minutes - the time it had a lock on) It is required that the myFcronJob.sh runs after 60 minutes

Example

  1. Cron job starts at 8am and runs for 5 minutes
  2. Fcron is about to start at 8:01am too but it had noticed the lock is in place
  3. Fcron waits for Cron job to finish
  4. Fcron finally runs at 8:05am
  5. Fcron will run 61 minutes from 8:01am which will result in next iteration to start at 9:02am instead of expected 9:06am

I was reading man page for fcrontab with hope there is some useful flag but couldn't understand much. Help appreciated

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.