How to set up 'cron' for a frugal install.


Forum: DSL Tips and Tricks
Topic: How to set up 'cron' for a frugal install.
started by: gjhicks

Posted by gjhicks on May 29 2006,12:10
Hi,

Am using a frugal install DSL to run a server box, that is up all the time.  The various logs grow (alarmingly!) over time, specially the privoxy logs.

What to do?  After deciding the getting 'logrotate' to work in DSL was too much bother, decided to use a simple a cron job to 'rotate' the logs but no cron in basic DSL.  So, below is how I got cron to work in DSL and to always be available after a reboot.

1) Call a script (as root) like the one below from 'bootlocal.sh'.  It turns out that to get cron to install/function, a 'mail transport agent' is required.  Although I may well be wrong, it seemed that 'masqmail' was the simplest/smallest to install.

#--------------------------------------------------------------------
#!/bin/sh
#
# Set up the alias file to be writeable, for installation
# of cron et al deb files. Setup /var/mail directory and
# mail user and group

rm /etc/aliases
rm /etc/aliases.db

cp /KNOPPIX/etc/aliases /etc/aliases
cp /KNOPPIX/etc/aliases.db /etc/aliases.db

mkdir /var/mail
groupadd mail
useradd mail -g mail

# Install cron, mail and helper deb files,
# example of 'debcron' file is below
dpkg -i `cat /home/dsl/debcron`

# setup cron editor to use 'nano'
ln -s /bin/nano-tiny /usr/bin/editor
#--------------------------------------------------------------------

2) This is what my 'debcron' file looks like, the deb files are kept on a partition separate from the frugal install partition.  The 'dpkg -i' line in the script 'reads' each line of this list and installs the deb files.

/mnt/hda7/cron_3.0pl1-72_i386.deb
/mnt/hda7/libident_0.22-2_i386.deb
/mnt/hda7/liblockfile1_1.03_i386.deb
/mnt/hda7/libperl5.6_5.6.1-8.9_i386.deb
/mnt/hda7/masqmail_0.1.16-2.1_i386.deb
/mnt/hda7/mailx_1%3a8.1.2-0.20020411cvs-1_i386.deb


3) A script file to 'rotate' the log files, modify to suit other process logs, to be called by cron.

#--------------------------------------------------------------------
#!/bin/sh -
# This is an attempt to write a script to manually
# rotate the some-process log files.
#

if [ -f /home/dsl/some-process/log/logfile.old.2.gz ] ; then
rm /home/dsl/some-process/log/logfile.old.2.gz
fi

if [ -f /home/dsl/some-process/log/logfile.old.1.gz ] ; then
mv /home/dsl/some-process/log/logfile.old.1.gz /home/dsl/some-process/log/logfile.old.2.gz
fi

if [ -f /home/dsl/some-process/log/logfile ] ; then
mv /home/dsl/some-process/log/logfile /home/dsl/some-process/log/logfile.old.1
gzip /home/dsl/some-process/log/logfile.old.1
touch /home/dsl/some-process/log/logfile
fi

# restart process
/usr/bin/killall -HUP /etc/init.d/some-process restart
#--------------------------------------------------------------------

4) I used 'crontab -e' to open the crontab control file and added a line like below, to run the cron job, in this case at midnight each day, with cron output not logged:

0 0 * * * /home/dsl/remove-log.sh >dev/null 2>&1


Hope that the above is of some use.

Geoff.

Posted by Fook on June 13 2006,14:23
please tell us, where to get your "debcron"-package or where to download a final cron.dsl.
i'm no debian-user at all (prefer FreeBSD), so i've no access to debian-packages via dpkg or else and unfortunatly the little DSL-Computer has no networkconnection at all.

thx for your work. :-)
Fook.

Posted by newOldUser on June 13 2006,15:46
Fook,

If you can't install cron or run into problems trying to do it there is an alternative way to schedule tasks. These threads talks about it:
< In the forum >
< In the blog area >

Posted by Fook on June 14 2006,04:47
Thank you very much for your great scripts, newOldUser :)
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.