Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
fcron [2015/06/01 16:12]
steve
fcron [2015/06/01 16:13] (current)
steve [fcron Samples]
Line 17: Line 17:
  
 See ''​man 5 fcrontab''​ See ''​man 5 fcrontab''​
- 
-<​code>​ 
-# Get our mails every 30 minutes ​ 
-@ 30 getmails -all 
- 
-# make some security tests every 48 hours of system up time,  
-# force a mail to be sent to root even if there is no output ​ 
-@mailto(root),​forcemail 2d /​etc/​security/​msec/​cron-sh/​security.sh 
-</​code>​ 
-<​code>​ 
-       # use /bin/bash to run commands, ignoring what /etc/passwd says 
-       ​SHELL=/​bin/​bash 
- 
-       # mail output to thib, no matter whose fcrontab this is 
-       ​!mailto(thib) 
- 
-       # define a variable which is equivalent to " Hello thib and paul! " 
-       # here the newline characters are escaped by a backslash (\) 
-       # and quotes are used to force to keep leading and trailing blanks 
-       TEXT= " Hello\ 
-        thib and\ 
-        paul! " 
- 
-       # we want to use serial but not bootrun: 
-       ​!serial(true),​b(0) 
- 
-       # run after five minutes of execution the first time, 
-       # then run every hour 
-       ​@first(5) 1h   echo "Run every hour" 
- 
-       # run every day 
-       @ 1d echo "fcron daily" 
- 
-       # run once between in the morning and once in the afternoon 
-       # ​ if systems is running at any moment of these time intervals 
-       ​%hours * 8-12,14-18 * * * echo "Hey boss, I'm working today!"​ 
- 
-       # run once a week during our lunch 
-       ​%weekly * 12-13 echo "I left my system on at least once \ 
-        at lunch time this week." 
- 
-       # run every Sunday and Saturday at 9:05 
-       5 9 * * sat,sun echo "Good morning Thibault!"​ 
- 
-       # run every even days of march at 18:00, except on 16th 
-       0 18 2-30/2~16 Mar * echo "​It'​s time to go back home!" 
- 
-       # the line above is equivalent to 
-       & 0 18 2-30/2~16 Mar * echo "​It'​s time to go back home!" 
- 
-       # reset options to default and set runfreq for lines below 
-       ​!reset,​runfreq(7) 
- 
-       # run once every 7 matches (thanks to the declaration above), 
-       # so if system is running every day at 10:00, this will be 
-       # run once a week 
-       & 0 10 * * * echo "if you got this message last time 7 days ago,\ 
-        this computer has been running every day at 10:00 last week.\ 
-        If you got the message 8 days ago, then the system has been down \ 
-        one day at 10:00 since you got it, etc" 
- 
-       # wait every hour for a 5 minutes load average under 0.9 
-       ​@lavg5(0.9) 1h echo "The system load average is low" 
- 
-       # wait a maximum of 5 hours every day for a fall of the load average 
-       ​@lavgand,​lavg(1,​2.0,​3.0),​until(5h) 1d echo "Load average is going down" 
- 
-       # wait for the best moment to run a heavy job 
-       ​@lavgor,​lavg(0.8,​1.2,​1.5),​nice(10) 1w echo "This is a heavy job" 
- 
-       # run once every night between either 21:00 and 23:00 or 
-       # ​  ​between 3:00 and 6:00 
-       ​%nightly,​lavg(1.5,​2,​2) * 21-23,3-6 echo "​It'​s time to retrieve \ 
-        the latest release of Mozilla!"​ 
-</​code>​ 
  
 ==== fcron vs. vixie-cron ==== ==== fcron vs. vixie-cron ====
  
 ''​fcron''​ uses a dedicated user to run root commands (systab). ​ vixie-cron uses root to run the commands as, and set it's own variables (see /​etc/​crontab) that override default environment variables (such as HOME). ​ I like fcron better because it is more predictable and doesn'​t change things around. ​ Debugging scripts that run as cron jobs is tricky, and the less surprises, the better. ''​fcron''​ uses a dedicated user to run root commands (systab). ​ vixie-cron uses root to run the commands as, and set it's own variables (see /​etc/​crontab) that override default environment variables (such as HOME). ​ I like fcron better because it is more predictable and doesn'​t change things around. ​ Debugging scripts that run as cron jobs is tricky, and the less surprises, the better.