Koozali.org: home of the SME Server
Obsolete Releases => SME Server 8.x => Topic started by: turandot on August 16, 2014, 10:44:48 AM
-
All,
I have setup SME 8.1 to run as a backup server using Affa 3: it does not provide any other services. The backup job is done every day on 06:30 am. Since the server is useless for 23 hours each day, the backup server is waked by WoL on 06:20 each day by my productive SME server. Additionally the backup server is sent back to sleep (signal-event halt) for the rest of the day on 07:20 by a custom cron job template. So far, so good.
Looking into the crontab, there are a couple of jobs that are foreseen to run at times when the server normally sleeps:
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
I understand that this part is generated from /etc/e-smith/templates/etc/crontab/10runparts . Should I adapt this template e.g. to the following?
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 7 * * * root run-parts /etc/cron.daily
07 7 * * 0 root run-parts /etc/cron.weekly
12 7 1 * * root run-parts /etc/cron.monthly
What about
# logrotate
12 1 */7 * * root /sbin/e-smith/signal-event logrotate
I understand that this part is generated from /etc/e-smith/templates/etc/crontab/65_logrotate . Should I adapt this template e.g. to the following?
# Just for now, do it each morning. Add logic here if we want
# to be able to tune the frequency
my $minute = 12;
my $hour = 07;
my $day = "*/$interval";
Now /etc/e-smith/templates/etc/crontab/check4updates . Should I adapt this template e.g. to the following?
if ($freq eq 'weekly') {
$min = 25;
$dom = '*';
$dow = 0;
} elsif ($freq eq 'monthly') {
$min = 25;
$dom = 1;
$dow = '*';
} else {
$min = 25;
$dom = '*';
$dow = '*';
}
Squid is not used, therefore I would leave the related template /etc/e-smith/templates/etc/crontab/squid unchanged. Is this OK?
Now template /etc/e-smith/templates/etc/crontab/statusreport. Here I don't understand where the contents of the variables
my $dow = ${statusreport}{DayOfWeek};
my $hour = ${statusreport}{Hour};
my $minute = ${statusreport}{Minute};
are coming from. As an example: how is $dow generated? Where is the variable ${statusreport}{DayOfWeek} defined? Should I change something here?
Thanks, turandot
-
Here I don't understand where the contents of the variables
my $dow = ${statusreport}{DayOfWeek};
my $hour = ${statusreport}{Hour};
my $minute = ${statusreport}{Minute};
are coming from. As an example: how is $dow generated? Where is the variable ${statusreport}{DayOfWeek} defined?
You either haven't read, or haven't understood, the developers' guide section about the configuration database and templates.
Within templates, all entries in the configuration database are available as pre-defined perl variables. So 'config show statusreport' is available as %statusreport within the template. So here $dow will be set to the value of 'config getprop statusreport DayOfWeek'.
-
You either haven't read, or haven't understood, the developers' guide section about the configuration database and templates.
Within templates, all entries in the configuration database are available as pre-defined perl variables. So 'config show statusreport' is available as %statusreport within the template. So here $dow will be set to the value of 'config getprop statusreport DayOfWeek'.
Charlie,
many thanks for pointing to the predefined variables, I obviously missed that part, this is clear now.
On the other hand, other variables are "hard coded" in the templates, e.g. like those parts in /etc/e-smith/templates/etc/crontab/10runparts . Should I adapt the Cron times for my use case?
Many thanks,
turandot
-
On the other hand, other variables are "hard coded" in the templates, e.g. like those parts in /etc/e-smith/templates/etc/crontab/10runparts . Should I adapt the Cron times for my use case?
Yes, the whole point of custom templates is that you can change the bits that don't suit your needs.
-
Charlie,
thanks a lot once again. I have applied the changes, and all worked out well. '/etc/crontab' looks nice now with adapted templates and properties. The jobs will run now in a time slot, where the server is up and running.
turandot
-
@stephdl,
shall we try to put this in a how-to wiki page with a sensible title?
guest
(typo in nick)
-
RequestedDeletion, stephdl
...a how-to wiki page with a sensible title?
It could be added here
http://wiki.contribs.org/Template_Tutorial
-
Janet,
thanks, good suggestion, good place.
guest
-
There may be a way to use 'anacron' to automatically run your daily, weekly and monthly cronjobs without templating each job:
http://serverfault.com/questions/551425/cron-to-anacron-migration-process
-
RequestedDeletion, stephdl
It could be added here
http://wiki.contribs.org/Template_Tutorial
Please do it for any takers :)