Creating schedules to run on specific days.
-
Hello,
i'd like to know if it is possible to configure a schedule to run on, say some specific day of month; for example first sunday of every month.
i first tried to click something together in the xoa-web gui, but i hadn't any success with this method so i tried editing/creating said schedule via xo-cli - but as far as im concerned you are only allowed to use the cron notation for the schedule rules.
[14:00:53][root@mgmt:~]$ xo-cli schedule.getAll [ { "jobId": "40c62026-9219-4a37-91d3-e41b359d6338", "name": "foo", "enabled": true, "cron": "0 18 1 * *", "timezone": "Europe/Berlin", "id": "4d011d64-cd11-45cd-adf1-995ac44d1411" },
tl;dr: i'd like to create a schedule with this property:
0 0 1-7 * * [ $(date +\%u) -eq 7 ] && backup
i there a way to do that?
-
You maybe missed the small toggle in the UI "Switch to week days"
-
Thanks for your reply.
I tried to play around with it, but each time i switch to week days, the schedule loses its patterns for the month days.
My method was:
In month day view select day 1 to 7, switch to week day selection and select only sunday.But if i switch to week days like described, the pattern becomes like this:
Sunday, September 13, 2020, 6:00 PM
Sunday, September 20, 2020, 6:00 PM
Sunday, September 27, 2020, 6:00 PMand so on...
-
Ping @Rajaa-BARHTAOUI or @badrAZ on this
-
Thank you.
I will try the same procedure on another XOA;
perhaps this behaviour is due to some fault with the one i'm trying to create the schedule on.
-
Works in the GUI the same on each of my 5 XOA servers.
so i edited the schedule via xo-cli
[15:10:04][root@mgmt:~]$ xo-cli schedule.set cron="0 18 1-7 * 0" id=4d011d64-cd11-45cd-adf1-995ac44d1411
as i expected the pattern becomes like this
Sunday, September 13, 2020, 6:00 PM Sunday, September 20, 2020, 6:00 PM Sunday, September 27, 2020, 6:00 PM Thursday, October 1, 2020, 6:00 PM Friday, October 2, 2020, 6:00 PM Saturday, October 3, 2020, 6:00 PM Sunday, October 4, 2020, 6:00 PM
-
i worked around my problem by creating a delta backup job with a full backup interval, such that the full backup would only run on a sunday every four weeks.
Still, for backup plans which do not contain incremental backups, this obviously wouldn't work.
-
Hi @pianon
Unfortunately, there is an exception in cron when the
day of week
and theday of month
are set together.if both "day of month" and "day of week" are restricted (not "*"), then one or both must match the current day
https://en.wikipedia.org/wiki/CronSo, we have no way to tell cron to execute a backup job each Sunday of the first week of the month.
-
Hello and thanks for replying @badrAZ
Ye i was curious how you implemented the cron schedules in XOA.
Of course, cron doesn't allow for an and-logic in itself so i wondered if i could prepend some condition to the backup job.
On systems which allow creating manual entries in cron-files i usually do as i showed the first posting, if i wish for more specificity. (and i suspect you don't edit crontabs in XOA by yourself)
Again, like this (or whatever your condition might be)
0 0 1-7 * * [ $(date +\%u) -eq 7 ] && backup
It would mean, the schedule runs every day of month from 1 to 7, but the backup would only run if the previous statement exits with zero which is when day of week equals to 7.
is there a way in XOA to configure a job or so to mimic this behaviour?
-
Currently, there is no way to add a predicate to the job execution.
But, it's possible to do a work-around that responds to your need using
xo-cli
and yourcron
.You can let your
cron
run manually the backup job usingxo-cli backupNg.runJob id:jobId schedule:scheduleId
. -
Yes that makes sense, thank you very much.
Makes me think managing backups via
xo-cli
like you proposed would work a lot smoother for multiple XOA instances versus doing it in the gui.Is it even mandatory for a Job to also have a schedule attached, if i run it using
/etc/crontab
?
i guess i'll figure this one out for myself. -
Yes, backup jobs require attached schedules to be executed properly.