Root Crontab Tasks/Timings

Status
Not open for further replies.

YukonKnights

Cadet
Joined
Aug 1, 2016
Messages
2
I have finished setting up my Freenas server, and I am making a few adjustments to ensure that whilst it is not going to be running 24/7, all required scrubs/SMART tests etc. run when it is scheduled to be on. I know that having it running 24/7 is probably best, but when it is unlikely to be used for at least 18 hours of each day, I am not prepared to just let it burn electricity.

To this end I have started by running a simple shutdown script that shuts the system down at midnight unless a scrub or SMART test is scheduled later that night (currently all set to start at 2 am), in which case the machine will stay on until midnight the following day. What I need to do now though is update the root crontab to ensure that the daily/weekly/monthly periodic tasks occur. I understand how crontabs work, and am happy mounting the root file system to ensure that changes persist after a reboot, but I have a few questions about what some of the tasks are, and how spaced out in time they need to be.

Below is a copy of the root crontab from /conf/base/etc/crontab

Code:
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD: src/etc/crontab,v 1.33.2.1 2009/08/03 08:13:06 kensmith Exp $
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute hour    mday    month   wday    who     command
#
*/5     *       *       *       *       root    /usr/libexec/atrun > /dev/null 2>&1
#
# Save some entropy so that /dev/random can re-seed on boot.
*/11    *       *       *       *       operator /usr/libexec/save-entropy > /dev/null 2>&1
#
# Rotate log files only at midnight.
0       0       *       *       *       root    newsyslog > /dev/null 2>&1
#
# Perform daily/weekly/monthly maintenance.
1       3       *       *       *       root    periodic daily
15      4       *       *       6       root    periodic weekly
30      5       1       *       *       root    periodic monthly
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time.  See adjkerntz(8) for details.
1,31    0-5     *       *       *       root    adjkerntz -a > /dev/null 2>&1

0       *       *       *       *       root    /bin/sh /usr/local/sbin/save_rrds.sh > /dev/null 2>&1

5       3       *       *       *       root    /bin/sh /usr/local/bin/telemetry-cron.sh > /dev/null 2>&1

0       *       *       *       *       root    /usr/local/bin/python /usr/local/bin/mfistatus.py > /dev/null 2>&1
1,31    *       *       *       *       root    /usr/local/bin/python /usr/local/www/freenasUI/tools/alert.py > /dev/null 2>&1

15      3       *       *       *       root    /usr/local/bin/python /usr/local/www/freenasUI/tools/cachetool.py expire >/dev/null 2>&1
30      3       *       *       *       root    /usr/local/bin/python /usr/local/www/freenasUI/tools/cachetool.py fill >/dev/null 2>&1
45      3       *       *       *       root    /usr/local/bin/python /usr/local/www/freenasUI/middleware/notifier.py backup_db >/dev/null 2>&1
0       3       *       *       *       root    find /tmp/ -iname "sessionid*" -ctime +1d -delete > /dev/null 2>&1
30      */5     *       *       *       root    /etc/ix.rc.d/ix-kinit renew > /dev/null 2>&1


My first question is what do the cron jobs from line 27 onward do?
More importantly, my second question is whether the individual cron jobs have to be spaced out so far in time? For example, do the individual cron jobs on lines 34-37 have to be 15 minutes apart, or can they be 5 minutes (or less) apart?

Ideally my end goal will be to adjust all the timings on the individual cron jobs to run when I know for certain that the server will be on, but I would like them to run in as quick succession as possible.

As a final question, I have scheduled the boot pool to be scrubed every 7 days. Which crontab controls the timing of this srub, however?
Thanks for the help!
 

ethereal

Guru
Joined
Sep 10, 2012
Messages
762
this thread may get moved - they don't want any new threads in this section.
 

YukonKnights

Cadet
Joined
Aug 1, 2016
Messages
2
Yes you're right :(. I read all the rules but didn't spot the thread at the top of this section. Sorry for posting in the wrong place! I don't suppose you can delete a whole thread can you?
 

Mirfster

Doesn't know what he's talking about
Joined
Oct 2, 2015
Messages
3,215
D

dlavigne

Guest
Note that the system crontab shouldn't be manually edited. It is automatically generated from the config database and any updates or reboots would revert your manual edits to it.
 

Gunnar Grim

Cadet
Joined
Jun 30, 2017
Messages
2
Not sure if this helps but I have a similar setup with a slightly different solution. My NAS starts up at 7 am (Wake on RTC configured in "BIOS") and shuts down at 23 pm by a cron task configured in the Web GUI, with the poweroff command. I've ensured that scrubs etc are run during daytime, which is when we use it the least. To make the periodics run, I've set them up as ordinary cron tasks in the Web GUI, run by root. No need to mess with /etc/crontab since the NAS is always off when these are run.

IMO FreeNAS should have preconfigured cron tasks for the periodics instead of fixed in the crontab. That way you could easily change the times to suit your needs.

HTH,
Gunnar
 
Status
Not open for further replies.
Top