www.mamboteam.com
macsat.com - OpenWrt | Olegs Firmware  
Home arrow Tutorials - Oleg arrow Crobtab Tutorial
Tuesday, 14 October 2008
 
 
Main Menu
Home
About
News
Tutorials - OpenWrt (WR)
Tutorials - Oleg
Wiki (RDC Based Routers)
Online Shop
Forum
Downloads
Free Linux eBooks
Links
Search
Contact Us
We have 6 guests online
2717156 Visitors
Login
Welcome Guest.






Lost Password?
No account yet? Register
Old macsat.com
Nokia Unlock (Dansk)
Nokia Unlock (English)
XBins IRC Chat
Crobtab Tutorial PDF Print E-mail
(5 votes)
Written by macsat   
Friday, 25 November 2005
The guide is made using a ASUS WL-500G Deluxe (or WL-500GX as it is sometimes called).
It should however apply to all the ASUS wireless line of products that are Linux based. Theese products are to my knowledge :
  • ASUS WL-500b
  • ASUS WL-500bv2
  • ASUS WL-500g
  • ASUS WL-500g Deluxe (WL500-gx)
  • ASUS WL-HDD
  • If you are the lucky owner of any of the above devices, you have come to the right place.
    If you still dont have one of the above devices - dont hesitate, go buy one :-)

    After following the steps in this tutorial, your ASUS WL device will have all its normal functionality, and also enable you to run sheduled tasks at specified intervals.

    When running a server it is often nice to be able to run specific tasks at pre-defined intervals. Sometimes it is nice to be able to strip logs every day, check for internet connection every 5 minutes or do something else every XX minutes/hours/days/weeks/months.

    After following this tutorial you will be left with an easy-to-use crontab based system, that enables you to run tasks at specified intervals, with no knowledge about cron.
    The system is somewhat simular to the crontab implementation of RedHat

    Tutorial Index

    1. Prerequisites - What is needed to get started.
    2. Installing and Configuring cron

    Prerequisites

    All you need is :
  • One of the above Asus Wireless devices
  • An USB Harddrive or USB Memory Stick / Keyring with some 50-100 MB space.(For the WL-HDD you just need a regular Harddrive)
  • Firmware version 1.9.2.7-4 (or higher) by Oleg

    I consider your setup to be simular to the setup I created in the ipkg Tutorial

    Installing and Configuring cron

    As usual the joint efforts of Oleg, The Slug guys and others in the community, installing the software is very easy :
    ipkg install cron < enter >

    This will install the cron demon, and even install the startup script in /opt/etc/init.d/
    If you have followed my setup in the ipkg Tutorial cron will automaticly start at boot time

    Since crontab can be a pain to use for non-vi-Lovers, lets create a few dirs, where we can place scripts that can be ran at specified times
    mkdir /opt/etc/cron.5mins
    mkdir /opt/etc/cron.hourly
    mkdir /opt/etc/cron.daily
    mkdir /opt/etc/cron.weekly
    mkdir /opt/etc/cron.monthly

    In the above directories .sh scripts can now be placed, and after following the remaining few steps of this guide, they will run at pre-specified points in time

    Now use your favourite editor to change the file: /opt/etc/crontab to be something like this :
    SHELL=/bin/sh
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
    MAILTO=""
    HOME=/
    # ---------- ---------- Default is Empty ---------- ---------- #
    # Syntax for lines is : minute hour day month dayofweek command #
    */5 * * * * root run-parts /opt/etc/cron.5mins
    01 * * * * root run-parts /opt/etc/cron.hourly
    02 4 * * * root run-parts /opt/etc/cron.daily
    22 4 * * 0 root run-parts /opt/etc/cron.weekly
    42 4 1 * * root run-parts /opt/etc/cron.monthly

    Notice: In the above I have used "root". This should be changed to the login name that you use on the web interface of yor router. Default name for the ASUS devices is "admin".

    As also noted in the file, the syntax for each line is :
    minute hour day month dayofweek command

    To take an example, the command: run-parts /opt/etc/cron.weekly is executed at time :
    minute : 22
    hour : 4
    day : *
    month : *
    dayofweek : *

    Where "*" is a wild-card meaning "ALL".
    Thus the command is running : Every day of week, Every Month, Every Day at 4:22
    Note that cron uses a 24h clock.

    This means that 4:22 is 4:22 AM, 4:22 PM would be indicated as :

    22 16 * * 0 root run-parts /opt/etc/cron.weekly
    The special */5 in the first line, means that this job is executed every 5 mins. At the minutes 5, 10, 15.....55.

    Having created this config-file, all that is needed is the command "run-parts" which is not a part of the firmware.
    For this purpos I created a small script which I named run-parts and placed in /opt/bin
    A script like this will do the job:
    #!/bin/sh
    #
    # runparts.sh by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
    # intended for use with cron
    #
    # based on rc.unslung by unslung guys :-)
    #
    if [ -z "$1" ]
    then
    echo "Usage : $0 "
    fi

    RUNDIR=$1"/*"

    for i in $RUNDIR ;do

    # Ignore dangling symlinks (if any).
    [ ! -f "$i" ] && continue

    case "$i" in
    *.sh)
    # Source shell script for speed.
    (
    trap - INT QUIT TSTP
    set start
    . $i
    )
    ;;
    *)
    # No sh extension, so fork subprocess.
    $i start
    ;;
    esac
    done

    Remember to chmod the script to be executable :
    chmod +x /opt/bin/run-parts

    This should be it!

    In order to test the cron-system, you could try to make a small script in /opt/etc/cron.5mins called test.sh, like this :
    #!/bin/sh

    date >> /tmp/crontest.txt


    Remember to make it excutable :
    chmod 755 /opt/etc/cron.5mins/test.sh

    Try to reboot your router and let it run for some 10 or 15 minuts. Then you should see a list of timestamps in :
    /tmp/crontest.txt

    showing when the cron has been running the script

    I hope you found this tutorial useful.

  • Last Updated ( Tuesday, 10 January 2006 )
     
    < Prev   Next >
    Buy Router
    Linksys Wireless-N Broadband Router WRT300N
    Linksys Wireless-N Broadband Router WRT300N
    Recent Forum Topics
    Donations

    If you appriciate this site, please consider making a small donation.

    All donations will be used to cover expenses from running macsat.com.

    Sponsored Ads
     
    Top! Top!