summaryrefslogtreecommitdiff
blob: 7c4351ec56feb268e2fca4c9dd6e05457fecee31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
#
# $Header: /var/cvsroot/gentoo-x86/sys-apps/cronbase/files/run-crons,v 1.5 2002/06/23 17:37:19 bangert Exp $
#
# 23 Jun 2002; Jon Nelson <jnelson@gentoo.org> run-crons:
#
# fixed a race condition, where cron jobs and run-crons wanted to delete
# touch files
#
# 20 Apr 2002; Thilo Bangert <bangert@gentoo.org> run-crons:
#
# moved lastrun directory to /var/spool/cron/lastrun
#
# Author: Achim Gottinger <achim@gentoo.org>
#
# Mostly copied from SuSE
#
# this script looks into /etc/cron.[hourly|daily|weekly|monthly]
# for scripts to be executed. The info about last run is stored in 
# /var/spool/cron/lastrun

mkdir -p /var/spool/cron/lastrun

#

for BASE in hourly daily weekly monthly
do
    CRONDIR=/etc/cron.${BASE}

    test -d $CRONDIR || continue

    # if there is no touch file, make one then run the scripts 
    if test ! -f /var/spool/cron/lastrun/cron.$BASE
    then

	touch /var/spool/cron/lastrun/cron.$BASE

	set +e
	for SCRIPT in $CRONDIR/*
	do
	    test -d $SCRIPT && continue
	    if test -x $SCRIPT ; then
		$SCRIPT
	    fi
	done
    fi
done

#

touch /var/spool/cron/lastrun
find /var/spool/cron/lastrun -newer /var/spool/cron/lastrun -exec /bin/rm -f {} \;