How can I setup more complex cron schedules

Hi Guys,

Cron question here related to backups - we've started using virtualmin backups but can't figure out how to setup the following schedule in virtualmin (we can set it up in non-virtualmin environments).

- Daily incremental at midnight Monday - Saturday
  - cron schedule = 0 0 * * MON-SAT /command-to-run

- Weekly full at midnight Sunday
  - cron schedule = 0 0 8-31 * SUN /command-to-run

- Monthly full at midnight FIRST Sunday of month
  - cron schedule = * * 1-7 * SUN /command-to-run

The weekly and monthly cron schedules above of course do not work since this is a known cron issue and those schedules will actually run every day 8-31 and 1-7 AND each Sunday.

The solution is very simple but I have been unable to figure out how to integrate it with the virtualmin backup (which we want to continue using to have logs, s3 integration, etc).

The fix for both the weekly and monthly cron schedule is as follows:

- Weekly full at midnight Sunday
  - cron schedule = 0 0 8-31 * * [ "$(date '+\%a')" = "Sun" ] && /command-to-run

- Monthly full at midnight FIRST Sunday of month
  - cron schedule = * * 1-7 * * [ "$(date '+\%a')" = "Sun" ] && /command-to-run

So, where are the cron schedules kept? I have been unable to locate them so I can add the inline date evaluation above to the cron entry. Also, it would be cool if this type of scheduling could be added to virtualmin - nothing fancy but the ability to manually edit the cron entry would be very handy.

Thanks!
-- Craig

Status: 
Active

Comments

In Virtualmin on the backup schedule form, you can select "Complex schedule" and click the button to choose any schedule that cron supports.

Clearly I didn't explain myself well. Let me simplify the question.

Where are the backup cron schedules stored? I need to add an in-line date evaluation to the cron schedule. This cannot currently be done inside virtualmin.

Thanks!
-- Craig

Webmin doesn't use regular cron for running backups - there are run from inside its own server process to save memory. So it isn't possible to add that extra in-line evaluation.

Oh, didn't realize that. It seems other things do use the regular cron schedules (webalizer, awstats, bandwidth, etc). Is there a specific reason for this related to backups?

Thanks!
-- Craig

Only because we haven't completed the full migration to Webmin's internal cron system yet.