What's new

The last cru task always gets corrupted? ac68u ac86u ax86u

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

MissingTwins

Regular Contributor
On every occasion, unplug and re-plug the router power will cause the last cru task malformed as below.
The last one means the last shown with cru l, so sometimes, others get corrupted but always at the last position of cru l.

This problem lasts for several years, till current 386.7_2
>cru l
*/1 * * * * /opt/etc/init.d/S90zerotier-one.sh start #ZeroTierDaemon#
*/5 * * * * /jffs/scripts/cloudflare-ddns-update.sh 4 mydomain.com ipv4#cloudflare.ipv4#
*/5 * * * * /jffs/scripts/cloudflare-ddns-update.sh 6 mydomain.com ipv6#cloudflare.ipv6#
*/2 * * * * /jffs/scripts/rdp-ipv6-mapping.sh #RdpIPv6Daemon#
0 10 * * * echo nop &>/dev/null #DummyDaemon#
00 2 * * Mon sh /opt/share/diversion/file/update-bl.div reset #Diversion_UpdateBL#
20 5 * * * sh /opt/share/diversion/file/rotate-logs.div #Diversion_RotateLogs#
20 17 * * * diversion count_ads count #Diversion_CountAds#
30 12 * * * service restart_letsencrypt #LetsEncrypt#
*/2 @2 @2 @2 @2 /opt/etc/init.d/server-guard.sh start #ServerDaemon#

Sometime the corrupted task gets quoted like this
"*/1 * * * * /opt/etc/init.d/S90zerotier-one.sh start" #ZeroTierDaemon#
And both of the corrupted tasks can be fixed manually with cru d/cru a.

cru tasks are added by wan-event shown as below
/jffs/scripts/wan-event
Bash:
#!/bin/sh
echo "wan-event Enter"
logger -t "wan-event" -c "Enter" -p user.notice
logger -t "wan-event" -c "WAN"$1", eventType="$2" " -p user.notice

if [ "connected" == "$2" ]; then
    echo "Detect connection"
    logger -t "wan-event" "Detect connection" -p user.notice
    /jffs/scripts/myservices.sh
fi

echo "wan-event leaving"
logger -t "wan-event" "Leaving" -p user.notice

/jffs/scripts/myservices.sh
Bash:
#!/bin/sh
echo "Starting script myservices.sh"
logger -t "myservices.sh" -c "Enter" -p user.notice

#----------------------------------
cru a DummyDaemon "0 10 * * * echo nop &>/dev/null"
cru a ZeroTierDaemon "*/1 * * * * /opt/etc/init.d/S90zerotier-one.sh start"
cru a ServerDaemon "*/2 * * * * /opt/etc/init.d/server-guard.sh start"
cru a matrixbot "*/1 * * * * /jffs/scripts/matrixbot.sh myservices NN"

#----------------------------------
# Detecting ipv6 changing every 5 minutes
cru a cloudflare.ipv4 "*/5 * * * * /jffs/scripts/cloudflare-ddns-update.sh 4 mydomain.com ipv4"
cru a cloudflare.ipv6 "*/5 * * * * /jffs/scripts/cloudflare-ddns-update.sh 6 mydomain.com ipv6"

#----------------------------------
cru d cloudflare.delay4
cru a cloudflare.delay4 "*/1 * * * * /jffs/scripts/cloudflare-ddns-update.sh 4 mydomain.com ipv4 cloudflare.delay4"

cru d cloudflare.delay6
cru a cloudflare.delay6 "*/1 * * * * /jffs/scripts/cloudflare-ddns-update.sh 6 mydomain.com ipv6 cloudflare.delay6"

cru d RdpIPv6Daemon
cru a RdpIPv6Daemon "*/2 * * * * /jffs/scripts/rdp-ipv6-mapping.sh"
#----------------------------------
# remove double quote in zerotier task bug?
cru d DummyDaemon
cru a DummyDaemon "0 10 * * * echo nop &>/dev/null"

echo "after myservices.sh"
logger -t "myservices.sh" -c "Leaving" -p user.notice

It's so annoying, so I have added several more cru tasks to counter attack, and made a cru_guard.sh task
Bash:
#!/bin/sh

cat /jffs/scripts/myservices.sh | while IFS=  read -r line ; do
    cru_name=$(echo "$line" | grep -iPo '^\s*cru\s+a\s+\K[\w.-]+' )
    cru_body=$(echo "$line" | grep -iPo '^\s*cru\s+a\s+[\w.-]+\s+\"?\K[^"]+' )
    if [ -n "$cru_name" ] && [ -n "$cru_body" ] ;then
        #echo "${cru_name} | ${cru_body}"
        tst=$(echo "$task_body1" | grep -i "${cru_name}")
        if [ "$?" -eq 0 ];then
            echo "Found OnDuty Task $tst"
            tst2=$(echo "$tst" | grep -iPo "^(?:[*\/\d]+\s+){5}")
            if [ "$?" -ne 0 ];then
                cru d "${cru_name}"
                cru a "${cru_name}" "${cru_body}"
                sysLOG "Found malformed and reconstructed: ${cru_body}" error
            fi
            echo ""
        fi
    fi
done
 
Last edited:
You seem to be suggesting that a sudden loss of power is causing this corruption. But what I don't understand is what makes that situation different from a normal reboot? In both cases, the cronjobs are NOT persistent upon a reboot. They need to be reestablished in their entirety w/ the WAN event. I could understand the possibility of corruption if perhaps these cronjobs *were* persistent (i.e., stored in nvram). But they're NOT. The only thing persistent here is your scripts. Is it perhaps your script that's being corrupted?
 
You seem to be suggesting that a sudden loss of power is causing this corruption.
I usually power off the route for 10 seconds then power it up, so it should not be a brown-out condition.

I don't understand is what makes that situation different from a normal reboot?
I think for the the normal reboot, you have to click the reboot button on the WebUI, but I almost never do that, because if the router was dead, you couldn't access the WebUI anyway, if the WAN was down, rebooting was unnecessary unless the previous version WAN got stuck and I also couldn't login the router(Displaying a message about WAN is down but no where to fill the username and password), at last, I had to do a power-cycle.

Is it perhaps your script that's being corrupted?
If it was corrupted, it should happen every-time, but it's not.
And more, it seems not always being corrupted at the same clause, but always showing at the last, every cru a clause is prone to be corrupted, but always at timer field recently.
I have caught this issue on my ac68u ac86u & ax86u.

I think the there are something messed up when doing cold start.
Maybe some software race condition has happened.
 
I have never encountered this behaivor in any Asus router that I have had which includes: AC1900P, AC68U, AX86U, XT8, XD4 as well as my current 2 AC86U and 2 CT8 units.
 
I think the there are something messed up when doing cold start.
Maybe some software race condition has happened.
Do you have any other script that do cru a around that time?
I have a few in post-mount scripts right after a number of add-on scripts. I remember I had issue that some of it is not added in crontab after power cycle. After I add some delay I no longer have this issue.
 
Something you might want to try is NOT using the WAN event for these purposes. I would instead use the services-start script. That would provide assurance that the scheduler "service" was always up and ready to accept cronjobs. Because that's what I suspect is the problem here. You're just assuming that when the WAN event completes, cron is in a safe state. I'm not so sure that's a safe assumption. The WAN event should be reserved for those things actually dependent on the WAN being up and ready. I don't consider that a requirement for cron. And if that's a requirement for some of the cronjobs, then the cronjobs themselves need to be checking the WAN for connectivity, which frankly could come and go at anytime anyway.
 
Do you have any other script that do cru a around that time?
I have a few in post-mount scripts right after a number of add-on scripts. I remember I had issue that some of it is not added in crontab after power cycle. After I add some delay I no longer have this issue.
Thank you, I think add some delay is a good idea, I will try it later.

I used to have another script that do cru a zerotier, but it caused some cru tasks disappearing, so I put all cru tasks into a single script myservices.sh and called by wan_event only.
 
Something you might want to try is NOT using the WAN event for these purposes. I would instead use the services-start script.
assurance that the scheduler "service" was always up and ready to accept cronjobs.
Thank you, I think you might be right.
I haven't thought about the scheduler service might not be ready when powering up and wan_even are coming.
I will try to move cru tasks to services-start.
 

Similar threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top