V23sp2 Cron to reset factory defaults

Discussion in 'DD-WRT Firmware' started by mesu55, Dec 27, 2007.

  1. mesu55

    mesu55 Network Guru Member


    I have attempted several methods to get cron working on my wrt54gL router running the ddwrt v23sp2 mini. Cron is enabled in Administration/Management as is syslogd and logging.

    I am testing with just a normal reboot until I get cron right, then will tackle the code to do the factory reboot. I am logged in as root and working through SSH.

    Cron is set and running and I found entries online and they create the files but it seems cron just ignores them. My entries and commands so far are:

    echo "/sbin/reboot" > /tmp/lreboot2
    chmod +x /tmp/lreboot2
    echo "*/2 * * * * root /tmp/lreboot2" > /tmp/cron.d/lreboot2a

    ### I tried both spaces between the * in the cron line and tabs with no luck.
    ### I now have a file /tmp/lreboot2 and a file /tmp/cron.d/lreboot2a

    #cat /tmp/cron.d/lreboot2a */2**** root /tmp/lreboot2

    I waited more than the alloted 2 minutes and nothing. I then ran the command:

    # stopservice cron && startservice cron

    to restart the cron service. My syslog /var/log/messages file entry shows:

    #tail -50 /var/log/messages

    Jan 1 00:45:08 main cron.info cron[2689]: (CRON) STARTUP (fork ok)
    Jan 1 00:45:08 main cron.info cron[2689]: (crontabs) ORPHAN (no passwd entry)

    I wait again, still no go. As a note, there is another file named check_ps in /tmp/cron.d and it does not seem to show log entries of running either.

    #cat check_ps */2 * * * * root /sbin/check_ps

    If I enter just the command the router does reboot and erase all my files and entries I just made.


    Any help on this is greatly appreciated. I am not an extreme newbie, but scripting and command line entries are not my strong points either. I copied and modified for myself most of these commands from other posts online.


  2. mesu55

    mesu55 Network Guru Member


    The message above is fine and works fine. I had to use spaces between the *'s in the cron line and had a typo somewhere. After the umteenth time typing it all in it began working. I still need help as my reset command does not work from cron file.

    echo "mtd erase nvram"

    The line "mtd erase nvram" seems to do nothing, but the line "/sbin/reboot" does cause the unit to reboot. but all my original settings are still there.

    If someone has a proper "nvram" cleaning command that will reset the router to the firmware defaults please let me know. The command must work from a cron file. "mtd erase nvram" does work from SSH but not cron.


  3. mesu55

    mesu55 Network Guru Member


    Busy here this week.
    I finally got everything working. I will leave the posts in case they may help someone else.

    As I said before the crons above are correct and work.

    My problem is now with cron doing a reboot/reset to firmware defaults.

    Cron could not reboot without the PATH. The following works well.
    Set path to mtd. Tell mtd to erase nvram and to (-r) reboot when complete..
    (replace frb_in03min with the name of your file)

    echo "/usr/sbin/mtd -r erase nvram" > /tmp/frb_in03min
    chmod +x /tmp/frb_in03min
    echo "*/3 * * * * root /tmp/frb_in03min" > /tmp/cron.d/frb_in03min
    ~#stopservice cron && startservice cron

    Just need a soft reboot ? try:
    ~#echo "/sbin/reboot" > /tmp/rbtin3min

    (replace rbtin3min with the name of your file)

    Of course this is all erased once the router reboots soft or hard. To keep it requires change in startup script and activation of JFFS/JFFS2 and to place these files inside jffs area.


  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice