What's new

Cron job not running

  • 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!

JGrana

Very Senior Member
I have a fairly simple script called switchwan.sh in /jffs/scripts.
It starts with #!/bin/sh and is executable.

It runs a speedtest and if the Primary WAN is less than 10 Mbit if calls wan-failover.sh to switch.
There are some logger_t messages and I keep a running log file with the speedtest results.

Works fine from the command line.

I added a cron job like this to have it run every 30 minutes:

cru a "SwitchWan" "*/30 * * * * /jffs/scripts/switchwan.sh"

It shows up when I do a cru l

But I don't believe it ever starts. I get all the log info in /tmp/syslog.log and the log file gets updated every time I manually run it.

I see the correct line in /var/spool/cron/crontabs/admin and I have also done a "service restart_crond"

Any other ideas on how to troubleshoot cron issues?
 
What is the output of cru l?

try adding it like this:
Code:
cru a switchwan "*/30 * * * * sh /jffs/scripts/switchwan.sh"
 
Thanks, I think I found the culprit.

I was using "logger_t" instead of "logger -t".

Running happily!
 
Just FYI...

I had the similar issue days ago that one of my cron jobs did not run and no error log output. Then I ran "servive restart_crond" several times, not work. Try to remove it add it back on /var/spool/cron/crontabs/admin, not work, reboot the router and let it auto run the services-start script (cru a), still not work. And all other jobs were running well. That indicated the issue was not on the router/firmware side. Then I looked deeply into all my cron jobs and scripts and found there were two scripts that might have some confilict. Both of the scripts defined the same function:

ping_ip () {
ping -c 2 -W 1 -q $1 | grep packets | awk '{print $4}'
}

and the function was called every minute in both scripts.

Then I changed the function name in one script to something else, it resolved the issue.

If the crond job does not run and you believe your router's cron daemon is working well (other jobs are still running as expected) , then look into all your scheduled jobs and there might be some conflicts among them.
 

Latest threads

Sign Up For SNBForums Daily Digest

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