ASUS WL-Series XXXXXX Tutorial
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 (WL-500gx)
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, [http://www.nslu2-linux.org/]The Slug guys and others in the community, installing the software is very easy :
This will install the cron demon, and even install the startup script in /opt/etc/init.d/Code:ipkg install cron < enter >
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
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 timeCode: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
Now use your favourite editor to change the file: /opt/etc/crontab to be something like this :
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".Code: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
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 :
Where "*" is a wild-card meaning "ALL".Code:minute : 22 hour : 4 day : * month : * dayofweek : *
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 :
The special */5 in the first line, means that this job is executed every 5 mins. At the minutes 5, 10, 15.....55.Code:22 16 * * 0 root run-parts /opt/etc/cron.weekly
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:
Code:#!/bin/sh # # runparts.sh by macsat@macsat.com # 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
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 :Code:#!/bin/sh date >> /tmp/crontest.txt
Remember to make it excutable :
Try to reboot your router and let it run for some 10 or 15 minuts. Then you should see a list of timestamps in :Code:chmod 755 /opt/etc/cron.5mins/test.sh
/tmp/crontest.txt
showing when the cron has been running the script




Reply With Quote