Differences

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

Link to this comparison view

Next revision
Previous revision
fcron [2013/03/11 17:35]
127.0.0.1 external edit
fcron [2015/06/01 16:13]
steve [fcron Samples]
Line 1: Line 1:
 ====== fcron ====== ====== fcron ======
  
-  * [[Cron Jobs]] 
   * [[cron]]   * [[cron]]
- 
-fcron is the cron service running on ''​tahiti''​ and ''​moorea''​ to execute scheduled tasks. 
  
 === Gentoo Linux === === Gentoo Linux ===
Line 14: Line 11:
 [[https://​bugs.gentoo.org/​show_bug.cgi?​id=388371|bug 388371]] [[https://​bugs.gentoo.org/​show_bug.cgi?​id=388371|bug 388371]]
  
-=== Policy === 
- 
-The cron policy is to restrict access to creating cron jobs to user root.  Any cron jobs that need to be run are placed as shell scripts into one of these directories:​ 
- 
-  * ''/​etc/​cron.hourly''​ 
-  * ''/​etc/​cron.daily''​ 
-  * ''/​etc/​cron.weekly''​ 
-  * ''/​etc/​cron.monthly''​ 
- 
-The shell scripts can use ''​su''​ to switch to a user account as needed and execute a job. 
- 
-An example command would be: 
- 
-<​code>​su -l -c "/​home/​user/​bin/​foo.sh --bar" user</​code>​ 
  
  
Line 34: 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.