作者: chanshui 時間: 2013-4-17 09:50 標題: crontab 應該點行
各位好, 其實個問題係, 我想令到隻 router 每一個星期都會自動 reboot 一次, 所以打算係隻 router 入邊加個 crontab 指令, 但加左似乎都無反應, 請指教邊度有錯~
因為我想先嘗試個 crontab work 唔 work, 所以今次我只係用左 touch 呢個指令, 我係 crontab -e 入邊加左一句 */5 * * * * /bin/touch /home/root/test.txt
希望佢會每 5 分鐘 touch 一次個 test.txt, 咁我就知句 command work 唔 work, 但係, 無反應. 請問邊度出左問題呢?
請多多指教, 本人只係 linux 新手, 謝謝~
作者: HKSAR 時間: 2013-4-17 10:10
回復 1# chanshui
你隻router 咩MODEL 行咩OS ?
作者: chanshui 時間: 2013-4-17 10:19
ASUS RT-N56U, 而家用既俄仔個 firmware.
作者: thomas_kk 時間: 2013-4-17 13:55
正常/var/log既sys.log應該會有crontab既execution log(不是指你句command的log)
,而是記錄低os幾時幾分行過個command,先看看是否有execution的history吧
作者: chanshui 時間: 2013-4-17 14:22
謝謝, 我今晚返去睇一睇先~
作者: toylet 時間: 2013-4-17 20:52
提示: 作者被禁止或刪除 內容自動屏蔽
作者: lazyfai 時間: 2013-4-17 21:08
首先你要肯定個OS有冇行到任何 cron daemon (應該會見到一個 "crond" process行緊)
作者: chanshui 時間: 2013-4-17 21:57
在 log 入邊只係有一個叫 samba.log, 唔見有 sys.log
個 samba.log 都仲係空白的~
作者: chanshui 時間: 2013-4-17 22:13
回復 7# lazyfai
我都有呢個諗法, 但我可以點做先知? 謝謝~
作者: lazyfai 時間: 2013-4-17 23:16
你講清楚係邊個 router firmware 好啲, 我自己用過 dd-wrt openwrt.
作者: chanshui 時間: 2013-4-17 23:46
謝謝你~
我隻係 ASUS RT-N56U, 用緊俄仔個 firmware 048, 我 check 過, 我隻 N56U 無 dd-wrt... 謝謝你!
作者: archy 時間: 2013-4-18 05:19
你個 cron file 都無指定邊個 user 去 run
*/5 * * * * root touch /home/test.txt <<應該係咁寫
作者: ee9861 時間: 2013-4-18 09:10
ROUTER既野未必齊COMMAND, 同有機會比人改過COMMAND
作者: chanshui 時間: 2013-4-18 09:31
呢個 syntax 我都試左, 但都係無 touch 過個 file...
作者: chanshui 時間: 2013-4-18 09:35
但我試過就咁係 command prompt 打
/bin/touch /home/root/test.txt
個 test.txt 真係會 update 左個 last update date time, 咁我估句 command 應該無問題, 我反而覺得係, 我點知個 crond 係行緊呢?
我尋日再係 command 打左 uname -a, 出以下,
Linux RT-N56U 3.0.71 #9 Mon Apr 1 01:02:37 KRAT 2013 mips GNU/Linux
呢隻 kernal 個 crond daemon 應該點 start 呢? 謝謝~
作者: lazyfai 時間: 2013-4-18 09:36
http://code.google.com/p/rt-n56u ... ip&can=2&q=
呢個? 連名都冇,咁俄仔都有嘅...
作者: ee9861 時間: 2013-4-18 09:45
但我試過就咁係 command prompt 打
/bin/touch /home/root/test.txt
個 test.txt 真係會 update ...
chanshui 發表於 2013-4-18 09:35
有可能你行command個shell 唔係/bin/bash
作者: chanshui 時間: 2013-4-18 09:52
係呀係呀, 係呢個 firmware 呀~
佢都話佢有 crond 的, 但就唔係用 crontab, 但我打 crontab 又有反應, 咁唔知我做得啱唔啱, 謝謝師兄呀~
作者: chanshui 時間: 2013-4-18 09:53
呢個真係唔太識, 因為 linux 對於我黎講, 我真係好新手, 希望各位師兄幫忙, 再謝謝~
作者: 有你便有我 時間: 2013-4-18 15:21
入隻router打ps aux|grep cron
作者: chanshui 時間: 2013-4-18 20:01
打 ps aux 佢就鬧 usage, 我打 ps | grep cron 就有出野
/home/root # ps|grep cron
875 admin 1556 S crond
878 admin 1556 S crond
1139 admin 1556 S crond
1152 admin 1556 S crond start
1154 admin 1556 S crond abs
1160 admin 1556 S crond uname
1171 admin 1556 S crond start
1799 admin 1532 S grep cron
/home/root #
作者: archy 時間: 2013-4-18 22:36
command whoami
睇下你 user 係 admin 定係 root

