looking for inotifywait and similar help

Dan Nicholson dbn.lists at gmail.com
Wed Dec 3 04:16:54 UTC 2008


On Tue, Dec 2, 2008 at 3:30 PM, Patrice Dumas <pertusus at free.fr> wrote:
> Hello,
>
> Trying to have fcron do the same than cronie, that is regenerate
> binary crontabs when /etc/crontab /etc/cron.d/ (or /etc/fcrontab since it
> is the same, but for fcron) change, I made a script to watch for
> /etc/cron.d/ and /etc/crontab and /etc/fcrontab if they exist (and then
> launch a script coming from debian that does all the regeneration work).
> However the issue I have is that I don't know how to have inotifywait do
> something when /etc/crontab or /etc/fcrontab is created since if I give
> a non-existing file as argument it will error out.

I think if you want to catch file creation, you have to watch /etc,
wait for create events and filter for the crontab files. So, I think
it would have to be something like:

out=`inotifywait -e create /etc`; do
if [ $? = 0 ]; then
    set -- $out
    case "$3" in
    crontab|fcrontab) do stuff ;;
    *) ;;
    esac
fi

Or, more likely is that you'll have to check whether crontab or
fcrontab exist initially and modify your command accordingly.

--
Dan




More information about the devel mailing list