summaryrefslogtreecommitdiff
path: root/usr/src/cmd/cron
diff options
context:
space:
mode:
authorJohn Levon <john.levon@joyent.com>2019-08-01 13:52:59 +0000
committerJohn Levon <john.levon@joyent.com>2019-08-01 13:52:59 +0000
commitd0ca2b08e18a06d653279357d3fa022c0e12b0bf (patch)
treee092c37e6937874abecc2e7dc42246c53651b188 /usr/src/cmd/cron
parent7f874eb65f07035e3f808d58a70ad712248fde0a (diff)
downloadillumos-joyent-d0ca2b08e18a06d653279357d3fa022c0e12b0bf.tar.gz
OS-7685 smartos-live overlay should be merged into illumos-joyent
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Mike Gerdts <mike.gerdts@joyent.com> Approved by: Mike Gerdts <mike.gerdts@joyent.com>
Diffstat (limited to 'usr/src/cmd/cron')
-rw-r--r--usr/src/cmd/cron/Makefile23
-rw-r--r--usr/src/cmd/cron/crontab.root18
-rw-r--r--usr/src/cmd/cron/svc-cron42
3 files changed, 66 insertions, 17 deletions
diff --git a/usr/src/cmd/cron/Makefile b/usr/src/cmd/cron/Makefile
index d8df76960f..c45159969e 100644
--- a/usr/src/cmd/cron/Makefile
+++ b/usr/src/cmd/cron/Makefile
@@ -22,7 +22,7 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
DEFAULTFILES = cron.dfl
@@ -48,6 +48,7 @@ ROOTVAR = $(ROOT)/var
ROOTSPCRON = $(ROOTVAR)/spool/cron
ROOTCROND = $(ROOTETC)/cron.d
+ROOTCRONDCRONTABS = $(ROOTCROND)/crontabs
ROOTCRONTABS = $(ROOTSPCRON)/crontabs
ROOTATJOBS = $(ROOTSPCRON)/atjobs
ROOTLIBCRON = $(ROOTLIB)/cron
@@ -66,9 +67,6 @@ POFILES1= at.po crontab.po funcs.po batch.po
POFILES= $(POFILES1) atrm.po
$(POFILES1) := XGETFLAGS= -a -x $(PROG1).xcl
-ROOTDIRS = $(ROOTSPCRON) $(ROOTCROND) \
- $(ROOTCRONTABS) $(ROOTATJOBS)
-
ROOTPROG = $(PROG1:%=$(ROOTUSRSBIN)/%) $(PROG2:%=$(ROOTBIN)/%) \
$(SCRIPT:%=$(ROOTBIN)/%) \
$(XPG6PROG:%=$(ROOTXPG6BIN)/%) \
@@ -144,13 +142,9 @@ crontab := LDLIBS += -lsecdb -lpam -lzoneinfo
crontab.xpg6 := LDLIBS += -lsecdb -lpam -lzoneinfo
crontab.xpg4 := LDLIBS += -lsecdb -lpam -lzoneinfo
-lint := LDLIBS += -lproject -lsecdb -lcontract -lpam
-
$(XPG4) := CFLAGS += -DXPG4
$(XPG6) := CFLAGS += -DXPG6
-LINTFLAGS += -u
-
$(ROOTSVCSYSTEM)/cron.xml := FILEMODE = 0444
$(ROOTLIBSVCMETHOD)/svc-cron := FILEMODE = 0555
@@ -160,7 +154,7 @@ $(ROOTLIBSVCMETHOD)/svc-cron := FILEMODE = 0555
all : $(PROG) $(XPG4) $(XPG6) $(SCRIPT) $(XPG4SCRIPT) $(FILES)
install : all $(ROOTPROG) $(ROOTETCDEFAULTFILES) $(ROOTSYMLINK) \
- $(ROOTMANIFEST) $(ROOTMETHOD)
+ $(ROOTMANIFEST) $(ROOTMETHOD) $(ROOTCRONDCRONTABS)/root
$(PROG) : $$(OBJS)
$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
@@ -214,13 +208,14 @@ att2.c : att2.l att2.ed att1.c
ed - lex.yy.c < att2.ed
$(MV) lex.yy.c att2.c
-# Don't re-install directories installed by Targetdirs
-#$(ROOTDIRS):
-# $(INS.dir)
-
$(ROOTSYMLINK) :
$(RM) $@; $(SYMLINK) $(SYMLNKDEST) $@
+$(ROOTCRONDCRONTABS)/root: crontab.root
+ $(RM) $@; \
+ $(INS) -s -m $(FILEMODE) -f $(@D) crontab.root; \
+ $(MV) $(@D)/crontab.root $@
+
check: $(CHKMANIFEST)
$(POFILE): $(POFILES)
@@ -229,8 +224,6 @@ $(POFILE): $(POFILES)
clean :
$(RM) $(COBJS) att1.h att1.c att2.c
-lint : lint_SRCS
-
strip :
$(STRIP) $(PROG) $(XPG4) $(XPG6)
diff --git a/usr/src/cmd/cron/crontab.root b/usr/src/cmd/cron/crontab.root
new file mode 100644
index 0000000000..4153ad2d6a
--- /dev/null
+++ b/usr/src/cmd/cron/crontab.root
@@ -0,0 +1,18 @@
+## Rotate and trim the audit logs nightly.
+0 0 * * * /smartdc/bin/sdc-lastcomm -R 30
+## Run logadm hourly so that the minimum rotate interval is 1h
+0 * * * * /usr/sbin/logadm
+## Rotate vm.log files for any KVM VMs
+0 * * * * SDC_LOG_ROLL_BACKWARD=1 /usr/vm/sbin/rotate-kvm-logs.sh >> /var/log/rotate-kvm-logs.log 2>&1
+## Headnode should phone home nightly.
+0 1 * * * [ -x /opt/smartdc/bin/sdc-phonehome ] && /opt/smartdc/bin/sdc-phonehome
+## Delete saved core dumps over 7 days old
+15 0 * * * find /zones/*/cores -type f -mtime +7 -exec rm -f "{}" \;
+## Delete archived zone data over 7 days old
+30 0 * * * find /zones/archive/ -mount -maxdepth 1 -mindepth 1 -type d -mtime +7 -exec rm -rf "{}" \;
+## Delete logs to be uploaded over 7 days old if they aren't being consumed
+45 0 * * * [ -d /var/log/sdc/upload/ ] && find /var/log/sdc/upload/ -mount -maxdepth 1 -mindepth 1 -type f -mtime +7 -exec rm -f "{}" \;
+
+# NOTE: all entries above are in root's system-defined crontab; see the
+# crontab(1) man page.
+
diff --git a/usr/src/cmd/cron/svc-cron b/usr/src/cmd/cron/svc-cron
index 4def6071b8..55033608ee 100644
--- a/usr/src/cmd/cron/svc-cron
+++ b/usr/src/cmd/cron/svc-cron
@@ -22,8 +22,7 @@
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright 2012 Joyent, Inc. All rights reserved.
#
# Start method script for the cron service.
#
@@ -37,6 +36,45 @@ if [ -p /etc/cron.d/FIFO ]; then
fi
fi
+if smf_is_globalzone && [ -n "$(bootparams | grep '^headnode=true')" ]; then
+ #
+ # Randomize root's crontab so all HN's are not in sync.
+ #
+ utc_offset=`nawk -F= '{if ($1 == "utc_offset") print $2}' \
+ /usbkey/config.inc/generic`
+ [ -z "$utc_offset" ] && utc_offset=0
+
+ n=$(date +%S)
+ hr=$(($n % 5))
+ hr=$(($hr + $utc_offset))
+
+ n=$(date +%M)
+ mn=$(($n % 15))
+
+ nawk -v hr=$hr -v mn=$mn '{
+ if (substr($1, 1, 1) == "#") {
+ print $0
+ next
+ }
+ if (substr($2, 1, 1) == "*") {
+ print $0
+ next
+ }
+ if (length($0) == 0) {
+ print $0
+ next
+ }
+
+ printf("%d %d %s %s %s %s", mn, hr, $3, $4, $5, $6)
+ for (i = 7; i <= NF; i++)
+ printf(" %s", $i)
+ printf("\n")
+ mn += 10
+ }' /etc/cron.d/crontabs/root >/etc/cron.d/crontabs/root.$$
+ cp /etc/cron.d/crontabs/root.$$ /etc/cron.d/crontabs/root
+ rm -f /etc/cron.d/crontabs/root.$$
+fi
+
if [ -x /usr/sbin/cron ]; then
/usr/bin/rm -f /etc/cron.d/FIFO
/usr/sbin/cron &