瀏覽代碼

crontab example

Bob Mottram 11 年之前
父節點
當前提交
4bb8978a46
共有 1 個檔案被更改,包括 34 行新增3 行删除
  1. 34
    3
      beaglebone.txt

+ 34
- 3
beaglebone.txt 查看文件

681
 An example would look like:
681
 An example would look like:
682
 
682
 
683
 #+BEGIN_SRC: bash
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
 #+END_SRC
685
 #+END_SRC
686
 
686
 
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.
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
 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.
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
 You can replace the multiple freedns entries with a single line:
731
 You can replace the multiple freedns entries with a single line:
726
 
732
 
727
 #+BEGIN_SRC: bash
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
 #+END_SRC
735
 #+END_SRC
730
 
736
 
731
 Then save and exit and restart the cron daemon.
737
 Then save and exit and restart the cron daemon.
734
 service cron restart
740
 service cron restart
735
 #+END_SRC
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
 ** Set the host name
745
 ** Set the host name
738
 
746
 
739
 #+BEGIN_SRC: bash
747
 #+BEGIN_SRC: bash
6385
 reboot
6393
 reboot
6386
 #+END_SRC
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
 * Deprecated
6419
 * Deprecated
6389
 
6420
 
6390
 The following items have been deprecated until such time as a successful installation is achieved.
6421
 The following items have been deprecated until such time as a successful installation is achieved.