First, I created a mcron rpm. Nothing fancy, here's the spec file; modify to your liking:
CODE
Summary: Vixie Cron Replacement
Name: mcron
Version: 1.0.2
Release: 1.int
Source0: %{name}-%{version}.tar.gz
Patch0: %{name}-%{version}.patch
License: GPL
Group: Applications/System
BuildRoot: %{_builddir}/%{name}-root
%description
The GNU package mcron (Mellor's cron) is a 100% compatible replacement for Vixie cron. It is written in pure Guile, and allows configuration files to be written in scheme (as well as Vixie's original format) for infinite flexibility in specifying when jobs should be run. Mcron was written by Dale Mellor.
BuildRequires: guile-devel
Requires: guile
%prep
%setup -q
%patch0 -p1 -b .buildroot
%build
./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var --infodir=/usr/local/share/info --mandir=/usr/local/share/man
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%dir /usr
%dir /usr/share
%dir /usr/share/guile
%dir /usr/share/guile/site
%dir /usr/share/guile/site/mcron
%dir /usr/local
%dir /usr/local/share
%dir /usr/local/share/mcron
%dir /usr/local/share/info
%dir /usr/local/bin
%dir /var
%dir /var/run
%dir /var/cron
/usr/local/share/mcron/vixie-specification.scm
/usr/local/share/mcron/config.scm
/usr/local/share/mcron/job-specifier.scm
/usr/local/share/mcron/redirect.scm
/usr/local/share/mcron/core.scm /usr/local/share/mcron/vixie-time.scm
/usr/local/share/mcron/environment.scm
/usr/local/share/info/dir
/usr/local/share/info/mcron.info
/usr/local/bin/mcron
/usr/local/bin/crontab
/usr/local/bin/cron
Name: mcron
Version: 1.0.2
Release: 1.int
Source0: %{name}-%{version}.tar.gz
Patch0: %{name}-%{version}.patch
License: GPL
Group: Applications/System
BuildRoot: %{_builddir}/%{name}-root
%description
The GNU package mcron (Mellor's cron) is a 100% compatible replacement for Vixie cron. It is written in pure Guile, and allows configuration files to be written in scheme (as well as Vixie's original format) for infinite flexibility in specifying when jobs should be run. Mcron was written by Dale Mellor.
BuildRequires: guile-devel
Requires: guile
%prep
%setup -q
%patch0 -p1 -b .buildroot
%build
./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var --infodir=/usr/local/share/info --mandir=/usr/local/share/man
make
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%dir /usr
%dir /usr/share
%dir /usr/share/guile
%dir /usr/share/guile/site
%dir /usr/share/guile/site/mcron
%dir /usr/local
%dir /usr/local/share
%dir /usr/local/share/mcron
%dir /usr/local/share/info
%dir /usr/local/bin
%dir /var
%dir /var/run
%dir /var/cron
/usr/local/share/mcron/vixie-specification.scm
/usr/local/share/mcron/config.scm
/usr/local/share/mcron/job-specifier.scm
/usr/local/share/mcron/redirect.scm
/usr/local/share/mcron/core.scm /usr/local/share/mcron/vixie-time.scm
/usr/local/share/mcron/environment.scm
/usr/local/share/info/dir
/usr/local/share/info/mcron.info
/usr/local/bin/mcron
/usr/local/bin/crontab
/usr/local/bin/cron
mcron-1.0.2.patch ( for makefile.in )
CODE
--- mcron-1.0.2/makefile.in 2006-01-02 10:09:32.000000000 -0500
+++ mcron-1.0.2/makefile.in 2006-03-29 16:38:08.000000000 -0500
@@ -775,10 +775,10 @@
$(INSTALL) --mode='u=rwx' mcron$(EXEEXT) $(fpp)cron$(EXEEXT); rm -f $(fpp)crontab$(EXEEXT) > /dev/null 2>&1;
$(INSTALL) --mode='u=rwxs,og=rx' mcron$(EXEEXT) $(fpp)crontab$(EXEEXT);
- ./mkinstalldirs -m 'u=rwx' /var/cron;
- ./mkinstalldirs -m 'u=rwx,og=rx' /var/run;
- ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@;
- ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@/mcron;
+ $(install_sh) -d -m 'u=rwx' $(DESTDIR)/var/cron;
+ $(install_sh) -d -m 'u=rwx,og=rx' $(DESTDIR)/var/run;
+ $(install_sh) -d -m 'u=rwx,og=rx' $(DESTDIR)@GUILE_SITE@;
+ $(install_sh) -d -m 'u=rwx,og=rx' $(DESTDIR)@GUILE_SITE@/mcron;
else
echo "+++ WARNING: NON-ROOT INSTALL: ONLY mcron WILL BE INSTALLED, NOT ANY OF THE VIXIE REPLACEMENT PROGRAMS";
fi
+++ mcron-1.0.2/makefile.in 2006-03-29 16:38:08.000000000 -0500
@@ -775,10 +775,10 @@
$(INSTALL) --mode='u=rwx' mcron$(EXEEXT) $(fpp)cron$(EXEEXT); rm -f $(fpp)crontab$(EXEEXT) > /dev/null 2>&1;
$(INSTALL) --mode='u=rwxs,og=rx' mcron$(EXEEXT) $(fpp)crontab$(EXEEXT);
- ./mkinstalldirs -m 'u=rwx' /var/cron;
- ./mkinstalldirs -m 'u=rwx,og=rx' /var/run;
- ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@;
- ./mkinstalldirs -m 'u=rwx,og=rx' @GUILE_SITE@/mcron;
+ $(install_sh) -d -m 'u=rwx' $(DESTDIR)/var/cron;
+ $(install_sh) -d -m 'u=rwx,og=rx' $(DESTDIR)/var/run;
+ $(install_sh) -d -m 'u=rwx,og=rx' $(DESTDIR)@GUILE_SITE@;
+ $(install_sh) -d -m 'u=rwx,og=rx' $(DESTDIR)@GUILE_SITE@/mcron;
else
echo "+++ WARNING: NON-ROOT INSTALL: ONLY mcron WILL BE INSTALLED, NOT ANY OF THE VIXIE REPLACEMENT PROGRAMS";
fi
Next, I created /etc/virtualhosting/filelists/siteinfo.custom.sh containing the following:
CODE
#!/bin/bash
/bin/cat
/bin/echo "N:S,rpm:guile"
/bin/echo "N:S,rpm:mcron"
/bin/cat
/bin/echo "N:S,rpm:guile"
/bin/echo "N:S,rpm:mcron"
I didn't want mcron's cron daemon running on sites that weren't going to be using it. The virtualcron script we had been using ( with anacron on FC1 ) determined whether or not to run the virtual site's cron daemon by whether or not /home/virtual/$site/fst/usr/sbin/crond existed or not. Since the daemon exists on all virtual sites in our method, our virtual cron script decides if it will run the daemon based on whether or not /home/virtual/$site/fst/var/cron/tabs exists. If tabs/ exists, it will start cron for that virtual site. I also chose to start the daemon with the --noetc option, so that /home/virtual/$site/etc/crontab will not be run by the system and the virtual site.
Here is the virtualcron init script ( I think originally by Guarav Sabharwal ), slightly modified by me for mcron.
CODE
#!/bin/sh
#
# virtualcron Start virtual cron daemons
#
# chkconfig: 345 99 99
# description: virtualcron for domains
RETVAL=0
# See how we were called.
case "$1" in
start)
echo "Starting virtualcron for ALL sites"
cd /home/virtual
for domain in *.*
do
[[ ! -d ./$domain ]] && continue
if [[ -x /home/virtual/$domain/usr/local/bin/cron ]] && [[ -d /home/virtual/$domain/var/cron/tabs ]];
then
$0 domain-start $domain
fi
done
;;
domain-start)
OK="echo -en 033[1;32m"
FAIL="echo -en 033[1;31m"
END="echo -en 033[0;39m"
domain=$2
site=$(awk '$1 == "'"$domain"'" {print $3;exit}'
/etc/virtualhosting/mappings/domainmap)
ison=$(ls -ald /home/virtual/* |
egrep "$site/fst"'$' | fgrep -v virtual/admin)
if [ "x$ison" = "x" ]
then
echo "$domain not active."
exit
fi
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
if [ "x$pid" = "x" ]
then
/usr/sbin/chroot /home/virtual/$domain /usr/local/bin/cron --noetc
sleep 1
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
else
status="previously started - $pid"
fi
output=$(kill -0 $pid 2>&1 | sed -e 's/.*kill://')
if [ "x$output" = "x" ]
then
color=$OK
if [ "$status" = "" ]
then
status="started - $pid"
fi
else
color=$FAIL
status=failed
fi
printf "%-40s " $domain
$color
echo -n "[$status] "
$END
echo "$output"
;;
stop)
echo "Stopping virtualcron for ALL sites"
cd /home/virtual
for domain in *.*
do
[[ ! -d ./$domain ]] && continue
$0 domain-stop $domain
done
;;
domain-stop)
OK="echo -en 033[1;32m"
FAIL="echo -en 033[1;31m"
END="echo -en 033[0;39m"
domain=$2
site=$(awk '$1 == "'"$domain"'" {print $3;exit}'
/etc/virtualhosting/mappings/domainmap)
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
nopid=0
if [ "x$pid" = "x" ]
then
ison=$(ls -ald /home/virtual/* |
egrep "$site/fst"'$' | fgrep -v virtual/admin)
if [ "x$ison" = "x" ]
then
continue
else
nopid=1
status="previously stopped"
fi
fi
if [ $nopid = 0 ]
then
output=$(kill $pid 2>&1 | sed -e 's/.*kill://')
fi
if [ "x$output" = "x" ]
then
color=$FAIL
if [ "$status" = "" ]
then
status="stopped - $pid"
fi
else
color=$FAIL
status=failed
fi
printf "%-40s " $domain
$color
echo -n "[$status] "
$END
echo "$output"
;;
status)
UP="echo -en 033[1;32m"
DOWN="echo -en 033[1;31m"
END="echo -en 033[0;39m"
cd /home/virtual
for site in site*
do
domain=$(awk '$3 == "'"$site"'" {print $1;exit}'
/etc/virtualhosting/mappings/domainmap)
base="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null |
sed -e 's/^.* //' -e 's#/fst.*##')"
if [ "x$base" = "x" ]
then
ison=$(ls -ald /home/virtual/* |
egrep "$site/fst"'$' | fgrep -v virtual/admin)
if [ "x$ison" = "x" ]
then
continue
else
status="stopped"
color="$DOWN"
fi
else
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
status="running - $pid"
color="$UP"
fi
printf "%-40s " $domain
$color
echo -n "[$status]"
$END
echo
done
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
*)
echo "Usage: virtualcron {start|stop|domain-start|domain-stop|restart|status}"
exit 1
esac
exit $RETVAL
#
# virtualcron Start virtual cron daemons
#
# chkconfig: 345 99 99
# description: virtualcron for domains
RETVAL=0
# See how we were called.
case "$1" in
start)
echo "Starting virtualcron for ALL sites"
cd /home/virtual
for domain in *.*
do
[[ ! -d ./$domain ]] && continue
if [[ -x /home/virtual/$domain/usr/local/bin/cron ]] && [[ -d /home/virtual/$domain/var/cron/tabs ]];
then
$0 domain-start $domain
fi
done
;;
domain-start)
OK="echo -en 033[1;32m"
FAIL="echo -en 033[1;31m"
END="echo -en 033[0;39m"
domain=$2
site=$(awk '$1 == "'"$domain"'" {print $3;exit}'
/etc/virtualhosting/mappings/domainmap)
ison=$(ls -ald /home/virtual/* |
egrep "$site/fst"'$' | fgrep -v virtual/admin)
if [ "x$ison" = "x" ]
then
echo "$domain not active."
exit
fi
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
if [ "x$pid" = "x" ]
then
/usr/sbin/chroot /home/virtual/$domain /usr/local/bin/cron --noetc
sleep 1
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
else
status="previously started - $pid"
fi
output=$(kill -0 $pid 2>&1 | sed -e 's/.*kill://')
if [ "x$output" = "x" ]
then
color=$OK
if [ "$status" = "" ]
then
status="started - $pid"
fi
else
color=$FAIL
status=failed
fi
printf "%-40s " $domain
$color
echo -n "[$status] "
$END
echo "$output"
;;
stop)
echo "Stopping virtualcron for ALL sites"
cd /home/virtual
for domain in *.*
do
[[ ! -d ./$domain ]] && continue
$0 domain-stop $domain
done
;;
domain-stop)
OK="echo -en 033[1;32m"
FAIL="echo -en 033[1;31m"
END="echo -en 033[0;39m"
domain=$2
site=$(awk '$1 == "'"$domain"'" {print $3;exit}'
/etc/virtualhosting/mappings/domainmap)
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
nopid=0
if [ "x$pid" = "x" ]
then
ison=$(ls -ald /home/virtual/* |
egrep "$site/fst"'$' | fgrep -v virtual/admin)
if [ "x$ison" = "x" ]
then
continue
else
nopid=1
status="previously stopped"
fi
fi
if [ $nopid = 0 ]
then
output=$(kill $pid 2>&1 | sed -e 's/.*kill://')
fi
if [ "x$output" = "x" ]
then
color=$FAIL
if [ "$status" = "" ]
then
status="stopped - $pid"
fi
else
color=$FAIL
status=failed
fi
printf "%-40s " $domain
$color
echo -n "[$status] "
$END
echo "$output"
;;
status)
UP="echo -en 033[1;32m"
DOWN="echo -en 033[1;31m"
END="echo -en 033[0;39m"
cd /home/virtual
for site in site*
do
domain=$(awk '$3 == "'"$site"'" {print $1;exit}'
/etc/virtualhosting/mappings/domainmap)
base="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null |
sed -e 's/^.* //' -e 's#/fst.*##')"
if [ "x$base" = "x" ]
then
ison=$(ls -ald /home/virtual/* |
egrep "$site/fst"'$' | fgrep -v virtual/admin)
if [ "x$ison" = "x" ]
then
continue
else
status="stopped"
color="$DOWN"
fi
else
pid="$(egrep "r-xp.*virtual/$site/fst/usr/local/bin/cron"
/proc/*/maps 2>/dev/null | awk -F/ '{print $3}')"
status="running - $pid"
color="$UP"
fi
printf "%-40s " $domain
$color
echo -n "[$status]"
$END
echo
done
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
*)
echo "Usage: virtualcron {start|stop|domain-start|domain-stop|restart|status}"
exit 1
esac
exit $RETVAL
Adding new jobs:
chroot /home/virtual/$site/fst
su - admin
crontab -e