Browse Source

crontab example

Bob Mottram 11 years ago
parent
commit
4bb8978a46
1 changed files with 34 additions and 3 deletions
  1. 34
    3
      beaglebone.txt

+ 34
- 3
beaglebone.txt View File

@@ -681,12 +681,18 @@ Select "/dynamic DNS/" then click "/quick cron example/"
681 681
 An example would look like:
682 682
 
683 683
 #+BEGIN_SRC: bash
684
-4,9,14,19,24,29,34,39,44,49,54,59 * * * * root sleep 29 ; /usr/bin/timeout 120 wget -O - https://free\ dns.afraid.org/dynamic/update.php?ABCKDNRCLFHENSLKNFEGSBFLFF== >> /\ tmp/freedns_mysubdomain_us_to.log 2>&1 &
684
+4,14,24,34,44,54 * * * * root sleep 29 ; /usr/bin/timeout 200 wget -O - https://free\ dns.afraid.org/dynamic/update.php?ABCKDNRCLFHENSLKNFEGSBFLFF== >> /dev/null 2>&1 &
685 685
 #+END_SRC
686 686
 
687 687
 It's important to make sure that you change the *http* to *https*, since this will help to prevent a potential attacker from hijacking your site and redirecting it to a fake version for the purposes of obtaining your login details.
688 688
 
689
-Edit */etc/crontab* and append that to the end of the file.
689
+Edit */etc/crontab* and append that to the top of the file, underneath the heading line which looks like this:
690
+
691
+#+BEGIN_SRC: bash
692
+# m h dom mon dow user	command
693
+#+END_SRC
694
+
695
+In general the most frequently run crontab entries should be at the top.  Then save and exit.
690 696
 
691 697
 Via your router's firewall settings you should now open port 22 (secure shell).  This will allow you to ssh into your BBB from any location - not just your own local network.
692 698
 
@@ -725,7 +731,7 @@ emacs /etc/crontab
725 731
 You can replace the multiple freedns entries with a single line:
726 732
 
727 733
 #+BEGIN_SRC: bash
728
-*/10 * * * * root /usr/bin/timeout 60 /usr/bin/dynamicdns
734
+*/10 * * * * root /usr/bin/timeout 200 /usr/bin/dynamicdns
729 735
 #+END_SRC
730 736
 
731 737
 Then save and exit and restart the cron daemon.
@@ -734,6 +740,8 @@ Then save and exit and restart the cron daemon.
734 740
 service cron restart
735 741
 #+END_SRC
736 742
 
743
+If you want to know what a typical /crontab/ file might look like then see the [[Example crontab file]]
744
+
737 745
 ** Set the host name
738 746
 
739 747
 #+BEGIN_SRC: bash
@@ -6385,6 +6393,29 @@ Then reboot the server with:
6385 6393
 reboot
6386 6394
 #+END_SRC
6387 6395
 
6396
+** Example crontab file
6397
+
6398
+This is an example of what your crontab file might look like, with the more frequently run tasks at the top.  For the two most frequent tasks specific minutes within each hour are given and they're arranged to try to minimise the number of things running simultaneously.
6399
+
6400
+#+BEGIN_SRC: bash
6401
+# /etc/crontab: system-wide crontab
6402
+# Unlike any other crontab you don't have to run the `crontab'
6403
+# command to install the new version when you edit this file
6404
+# and files in /etc/cron.d. These files also have username fields,
6405
+# that none of the other crontabs do.
6406
+
6407
+SHELL=/bin/sh
6408
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
6409
+
6410
+# m            h dom mon dow user command
6411
+10,20,30,40,50 * *   *   *   root /usr/bin/timeout 120 /usr/bin/dynamicdns && /usr/bin/spamfilter myusername
6412
+15,35,55       * *   *   *   root cd /var/www/mydomainname/htdocs; /usr/bin/timeout 240 /usr/bin/php include/poller.php
6413
+17             * *   *   *   root cd / && run-parts --report /etc/cron.hourly
6414
+25             6 *   *   *   root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
6415
+47             6 *   *   7   root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
6416
+52             6 1   *   *   root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
6417
+#+END_SRC
6418
+
6388 6419
 * Deprecated
6389 6420
 
6390 6421
 The following items have been deprecated until such time as a successful installation is achieved.