Currently crond uses the modification time of the crontabs directory
to detect changes to the crontab files to decide whether to reload
them. This works fine when crontab creates or removes crontab files,
but when an existing crontab file is modified or replaced, it doesn't
change the modification time of the directory, so crond doesn't know
it should reload the crontab files. This patch fixes this by making
crontab remove the old crontab file (if it exists) before recreating
it, so the directory's modification time always changes when a crontab
is modified.
diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c
index 575398f2..ced5755e 100644
--- a/toys/pending/crontab.c
+++ b/toys/pending/crontab.c
@@ -234,6 +234,7 @@ static void update_crontab(char *src, char *dest)
   int fdin, fdout;
 
   snprintf(toybuf, sizeof(toybuf), "%s%s", TT.cdir, dest);
+  unlink(toybuf);
   fdout = xcreate(toybuf, O_WRONLY|O_CREAT|O_TRUNC, 0600);
   fdin = xopenro(src);
   xsendfile(fdin, fdout);
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to