From 374609e2d154289a96bac2a3efc470fa89a53225 Mon Sep 17 00:00:00 2001 From: thib Date: Sun, 31 Mar 2002 15:07:22 +0000 Subject: [PATCH] added a question about using fcron in scripts --- doc/en/faq.sgml | 96 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 23 deletions(-) diff --git a/doc/en/faq.sgml b/doc/en/faq.sgml index 9f262d4..97748fe 100644 --- a/doc/en/faq.sgml +++ b/doc/en/faq.sgml @@ -8,7 +8,7 @@ Foundation. A copy of the license is included in gfdl.sgml. --> - + Frequently Asked Questions @@ -70,28 +70,6 @@ A copy of the license is included in gfdl.sgml. by running "fcrontab -z" on all the fcrontabs. - - - How can I use fcrontab in scripts ? - - - - You can use pipes with "fcrontab -l" - (list the fcrontab) and "fcrontab -" - (read the new fcrontab from input). - For example : - echo -e "`fcrontab -l | grep -v exim`\n0 * * * * /usr/sbin/exim -q" | fcrontab - - - can be used to add a line. - Another way to do it would be to: - list the fcrontab settings into a temporary file - ("fcrontab -l > tmpfile"); - modify the temporary file ("echo $LINE >> tmpfile"); - replace the original fcrontab by the temporary; and finally, - remove the temporary file ("fcrontab tmpfile ; rm -f tmpfile"). - - - How can I prevent fcrontab from considering the first "word" @@ -160,6 +138,78 @@ A copy of the license is included in gfdl.sgml. + + + + How can I use fcrontab in scripts ? + + + + You can use pipes with "fcrontab -l" + (list the fcrontab) and "fcrontab -" + (read the new fcrontab from input). + For example : + echo -e "`fcrontab -l | grep -v exim`\n0 * * * * /usr/sbin/exim -q" | fcrontab - + + can be used to add a line. + Another way to do it would be to: + list the fcrontab settings into a temporary file + ("fcrontab -l > tmpfile"); + modify the temporary file ("echo $LINE >> tmpfile"); + replace the original fcrontab by the temporary; and finally, + remove the temporary file ("fcrontab tmpfile ; rm -f tmpfile"). + + + + + + + Can I use fcron from time to time, for instance in a script ? + + + Let's suppose you use fcron in your ppp-up script. Fcron can permit you to run some jobs at connection startup, but not at each connection, like it would be if the job was run directly by the ppp-up script : for instance, only once every week. + + Using fcron in a script : running a job once every day, week, etc, at dialup connection + You can use a script like : + +# A ppp-up script ... +# run the jobs pending, then returns : +fcron -f -y -o + + in conjunction with a fcrontab file like : + +# a fcrontab file ... +%random(no),weekly,stdout * * /a/command/to/download/latest/mozilla/release +%monthly,stdout * * * /update/junkbuster/config/files + + + You can also use fcron to run some jobs until the end of the connection. For instance, you can make fetchmail retrieve mails more often during connection : we suppose that it is configured to retrieve mails every hours, which launches a dialup connection if necessary, and we want it to check for mails every 5 minutes while connected. + + Using fcron in a script : running a job until the end of the connection + ppp-up script : + +# A ppp-up script ... +# run fcron at the beginning of the connection : +fcron -b + + ppp-down script : + +# A ppp-down script ... +# stop fcron at the end of the connection : +# -- Warning : killall may have unwanted effect on non linux systems -- +killall -TERM fcron + + the fcrontab : + +# a fcrontab file ... +@volatile,first(0) 5 fetchmail + + + + If you run fcron in several scripts, or if you run fcron as a daemon and want also to run fcron in scripts, then you should use fcron, fcrontab and fcrondyn's . + For more details, see fcron's options , , and in &fcron;(8), and fcrontab's options &optvolatile;, &optstdout;, &optfirst; in &fcrontab;(5) + + -- 2.50.1