list enabled periodic tasks

As trivial as it may sound, is there a way to list all periodic enabled tasks for a group (e.g., daily) without having to parse/grep and merge configuration files?
 
Similar to what /etc/defaults/rc.conf is for /etc/rc.conf, there's /etc/defaults/periodic.conf.
 
As trivial as it may sound, is there a way to list all periodic enabled tasks for a group (e.g., daily) without having to parse/grep and merge configuration files?
I think your question is: If you started "periodic daily" right now, which of the tasks would be run (or weekly or monthly or ...)? And perhaps even with what parameters?

Sadly, there is no such option. You can read the periodic program itself (it's /usr/sbin/periodic, and written in pretty clean shell script), and it does no options parsing. But what you could do: Quickly modify periodic itself, find the line where it executes the scripts (in my version it is line 136, in a loop over dir and file, and where $file is the command), and replace that line with just echo'ing the name of the file instead of running it.

If someone feels charitable, they could add argument parsing and a "-v" or "-n" option to periodic, and submit the patch to the maintainers via the mailing list.
 
This would require adapting all existing periodic scripts, because it is the scripts themselves that determine whether or not their task is enabled.
 
sh:
set |sort > /tmp/$$.1
. /etc/defaults/periodic.conf

source_periodic_confs
set |sort  > /tmp/$$.2
RES=$(comm -13 /tmp/$$.1 /tmp/$$.2)
for line in $RES
do
var=${line%=*}
how=${line##*=}
suf=${var##*_}
[ "$suf" != "enable" ] && continue
[ "$how" != "YES" -a "$how" != "yes" ] && continue
#echo "$var => $how"

grep -rl "case.*$var" /etc/periodic/
done
rm -f /tmp/$$.1 /tmp/$$.2
 
sh:
set |sort > /tmp/$$.1
. /etc/defaults/periodic.conf

source_periodic_confs
set |sort  > /tmp/$$.2
RES=$(comm -13 /tmp/$$.1 /tmp/$$.2)
for line in $RES
do
var=${line%=*}
how=${line##*=}
suf=${var##*_}
[ "$suf" != "enable" ] && continue
[ "$how" != "YES" -a "$how" != "yes" ] && continue
#echo "$var => $how"

grep -rl "case.*$var" /etc/periodic/
done
rm -f /tmp/$$.1 /tmp/$$.2

Nice idea!
I would elaborate a little more on this.
 
Back
Top