Cron not working [SOLVED - sort of...]

This forum is for all other ARMv5 devices

Cron not working [SOLVED - sort of...]

Postby greenman » Mon May 07, 2012 6:47 pm

I've got this in crontab : $this->bbcode_second_pass_code('', '* * * * * /home/user/scripts/checkcron.sh >> /home/user/log/cron/`echo $(date +"\%Y.\%m.\%d").cron.log` 2>&1')
checkcron.sh code: $this->bbcode_second_pass_code('', 'echo "Script run at: `date`" >> ~/croncheck.txt
echo "Script logged at: `date`"')
rc.d list shows that crond is set: STARTED][AUTO] crond.
I'm getting nothing in either /home/user/log/cron/2012.05.07.cron.log or /home/user/croncheck.txt
The files should generate automatically.

Directories are writable because the script run at commandline performs as expected:$this->bbcode_second_pass_code('', '/home/user/scripts/checkcron.sh >> /home/user/log/cron/`date +"%Y.%m.%d".cron.log` 2>&1')

I'm not sure why it's not running in cron. In fact right now, none of my scripts are running. So I've removed them all, and put just entered just this one cron job to diagnose the problem. No dice.

I have no cron.allow. Cron.deny is empty. Cron was working yesterday.

Any ideas?

EDIT: I rebooted. It seems to be working now. I'm not sure what caused cron to stop working properly. I'd be grateful for any input.
Last edited by greenman on Mon May 07, 2012 10:49 pm, edited 2 times in total.
POGO-B01
greenman
 
Posts: 24
Joined: Tue Apr 17, 2012 8:03 pm

Re: Cron not working

Postby Philoo » Mon May 07, 2012 8:19 pm

Did you check that your pogo's date and time are correct ? there is no rtc so the date and time need to be pulled from somewhere (NTP is installed default). I have seen some instances where the ntp daemon requires a manual command lline entry because the correction is too big.

also classical stuff for cronjob:
- script is indeed excutable
- the file /directory permissions are right for the user of relevance
- it's recommended to use full absolute path in cron at $PATH may not be set.
- not sure if ~ is interpreted/expanded in cron context try with an absolute path to a folder you KNOW is accessible ( /tmp ?)


HTH
Philoo
 
Posts: 102
Joined: Wed Aug 10, 2011 9:20 pm

Re: Cron not working

Postby greenman » Mon May 07, 2012 8:27 pm

$this->bbcode_second_pass_quote('Philoo', 'D')id you check that your pogo's date and time are correct ? there is no rtc so the date and time need to be pulled from somewhere (NTP is installed default). I have seen some instances where the ntp daemon requires a manual command lline entry because the correction is too big.

also classical stuff for cronjob:
- script is indeed excutable CHECK
- the file /directory permissions are right for the user of relevance CHECK
- it's recommended to use full absolute path in cron at $PATH may not be set. CHECK - $ which crond, $ /user/sbin/crond )
- not sure if ~ is interpreted/expanded in cron context try with an absolute path to a folder you KNOW is accessible ( /tmp ?) it is correctly interprested - or at least it was yesterday, eh? :)


HTH
Yes. Thank you for your reply Philoo.

I'd read somewhere that it's a good idea to restart openntpd daily. Is it possible that putting this in root's cron could have caused the timing to fail?

After reboot, now cron is working as expected. I certainly don't want to have to reboot very often. I'll have to keep watch on cron for a couple days to see what the deal is.
$this->bbcode_second_pass_code('', '0 12 * * * rc.d restart openntpd')
I was getting what I thought was the correct response for `date` at the command prompt even when testing my crons.
POGO-B01
greenman
 
Posts: 24
Joined: Tue Apr 17, 2012 8:03 pm

Re: Cron not working [SOLVED - sort of...]

Postby Philoo » Mon May 07, 2012 8:55 pm

MMM looks like your cron service basically failed / stopped.
I'm by no means an openntpd specialist but I think restating it completely is not necessary. What you'll want is "just" pull time form one of the servers and update the local clock.

check this out http://linux.die.net/man/8/ntpd, looks like you only need the cron job when you do not have the resources / internet access to keep the daemon running.

if you still need/want the cron job I think $this->bbcode_second_pass_code('', 'ntpd -g') would be all you need (-g to allow for larger than 1000 sec corrections).

several weeks ago I ran into things somewhat similar, tried a lot of things with cron, only to find out that the root cause was an inferior flash drive that finally gave up after a couple months. manual reboots would let the device fsck and operate ok until it hit a bad sector again.
Philoo
 
Posts: 102
Joined: Wed Aug 10, 2011 9:20 pm

Re: Cron not working [SOLVED - sort of...]

Postby greenman » Mon May 07, 2012 9:13 pm

$this->bbcode_second_pass_quote('Philoo', 'M')MM looks like your cron service basically failed / stopped.
I'm by no means an openntpd specialist but I think restating it completely is not necessary. What you'll want is "just" pull time form one of the servers and update the local clock.

check this out http://linux.die.net/man/8/ntpd, looks like you only need the cron job when you do not have the resources / internet access to keep the daemon running.

if you still need/want the cron job I think $this->bbcode_second_pass_code('', 'ntpd -g') would be all you need (-g to allow for larger than 1000 sec corrections).

several weeks ago I ran into things somewhat similar, tried a lot of things with cron, only to find out that the root cause was an inferior flash drive that finally gave up after a couple months. manual reboots would let the device fsck and operate ok until it hit a bad sector again.
Philoo, thanks again for your help.
As you suggest, I'm going to just drop the root crontab for restarting ntpd.
On a whim I tried 'ntpd -g'. Apparently arch linux for arm doesn't include the '-g' argument. $this->bbcode_second_pass_code('', '$ ntpd -g
ntpd: invalid option -- 'g'
usage: ntpd [-dSs] [-f file]
') If I start seeing the time stray from the correct time, I'll reboot.
It would suck if my flash drive has a bad sector or two. Especially since I just bought it a few weeks ago from Radio Shack on sale, but it was pretty cheap.
Again, thanks!
POGO-B01
greenman
 
Posts: 24
Joined: Tue Apr 17, 2012 8:03 pm


Return to Community Supported

Who is online

Users browsing this forum: No registered users and 4 guests