cron usage

David Henderson dhenderson at digital-pipe.com
Sat Jan 9 16:36:49 UTC 2016


Good morning Isaac, thanks for your help as well.  I'm going to be
working with this today to see what I can figure out and will reply
with my final solution.


>> Thanks for the reply Tito!  So does the -c parameter change the
>> parsing directory from /var/spool/cron/crontabs, or does it specify a
>> 'holding' directory for the individual cron jobs?  Also, does that
>> mean that I can't implement something like an /etc/cron.d directory
>> where any cron jobs within it are parsed, or can I create an
>> /etc/crontab file to parse that directory using run-parts?
>
>
> Busybox crond does not support /etc/crontab.
> run-parts runs all scripts in a directory, rather than providing a way to
> parse all files within it.
>
> Now, here's a script that should add all /etc/cron.d/* jobs with proper
> permissions to the right crontabs (assuming it works right; NOT TESTED!):
>
> #!/bin/busybox ash
>
> other_writeable () {
> 	MODE=`stat -c %05a "$1"` || return 1
> 	MODEG=`echo $MODE | cut -c 4`
> 	MODEO=`echo $MODE | cut -c 5`
> 	# if mode is 2-3 or 6+ (writeable bit is set), return 0
> 	test $MODEG -gt 1 -a $MODEG -lt 4 || test $MODEG -gt 5 || \
> 	test $MODEO -gt 1 -a $MODEG -lt 4 || test $MODEO -gt 5 || \
> 	return 0
> 	# not writeable
> 	return 1
> }
>
> {
>   for F in /etc/cron.d/*
>     do
>       other_writeable "$F" || cat "$F"
>     done
> } | grep -v '^#' | {
>   while read MIN H DOM MON DOW U EXEC
>     do
>       echo "$MIN $H $DOM $MON $DOW $EXEC" >> /var/spool/cron/crontabs/"$U"
>     done
> }
>
> Bear in mind that this script is a one-shot conversion tool; you would need
> to remove duplicates manually if you ran it automatically, and there's
> no rovision for removing cron jobs.
>
> HTH,
> Isaac Dunham
>


More information about the busybox mailing list