Time Condition BLF Hint not updating until call received

It’s going to provide a ton of insight. If the BLF changes when you run that command manually then that means that the command is not in the crontab.

The ticketing system is meant more for reporting bugs when the issue is known. It’s not a support dialog. Since this issue is (right now) only you two we must work through it in some medium to figure out what’s going on. Thats what the forums are for.

Then when the issue is narrowed down we can move forward with a solution.

So after I ran that command (/var/lib/asterisk/bin/schedtc.php --debug), the user is now reporting that the light goes out timely at 8am when it should. Does that command actually do something or is it purely informational and the timing is coincidental?

Yes. It changes the blf. Its the same command that is run automatically on the crontab.

You might have disabled the cron for this in advanced settings.

This PBX periodically has this issue. If I manually run /var/lib/asterisk/bin/schedtc.php --debug while the light is (falsely) lit, the light goes out and it works for awhile (typically several weeks). The issue will then occur again, and calling in or running the command fixes the issue.

In the Advanced Settings, ‘Enable Maintenance Polling’ is set to Yes and the Maintenance Polling Interval is set to 60.

Any suggestions?

Check the cron job in cron tab

It doesn’t look like there is anything related to freepbx, asterisk, schedtc, etc, etc in the crontab. Would it potentially be in one of the other cron files? Can you give me an example of what I should be looking for, or what is needed to be added?

Your assistance is appreciated.

This is what you should see on a 13 system:

# crontab -l -uasterisk | grep schedtc
* * * * * [ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php
1 Like

Andrew,

Somehow I missed your reply. Sorry and thank you for trying to move this forward.

/var/lib/asterisk/bin/schedtc.php --debug
Time Now:12:34|Wed|2|Aug|America/Los_Angeles

==Working with TimeCondition:Is During Business Hours==
INVERTED BLF: false (NOT_INUSE = NOT_INUSE & INUSE = INUSE)
OVERRIDE MODE: not set
=>06:45-18:00|mon-fri|*|*|America/Los_Angeles is now
TIME MATCHED: True (NOT_INUSE)
BLF MODE: True (NOT_INUSE)
Privilege: Command
Changing TC1 to NOT_INUSE


==Working with TimeCondition:Holiday==
INVERTED BLF: true (NOT_INUSE = INUSE & INUSE = NOT_INUSE)
OVERRIDE MODE: not set
=>11:09-11:10|*|*|*|America/Los_Angeles is not now
TIME MATCHED: False (NOT_INUSE)
BLF MODE: False (NOT_INUSE)
Privilege: Command
Changing TC3 to NOT_INUSE

I have not had a chance to see if the BLF updates when running this. I will try and check this tonight.

I do seem to have a crontab entry.

crontab -l -u asterisk | grep schedtc
* * * * * [ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php

I don’t see any entries in the cron logs however. Should I?

 grep schedtc /var/log/cron*  

I do believe that cron is running in general as I have entries in the logs for other items.

Thanks for the help!

Yes. You should see entries corresponding to the frequency you have set in advanced settings (mine is 5 min):

# grep schedtc /var/log/cron
Aug  2 13:35:01 lgaetzdev2 CROND[13899]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Aug  2 13:40:01 lgaetzdev2 CROND[14789]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Aug  2 13:45:01 lgaetzdev2 CROND[15697]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)

I think I have found the problem / solution!

I found these errors in the cron log:

 tail /var/log/cron
Aug  2 13:10:01 precendo CROND[15661]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:10:01 precendo CROND[15663]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:10:01 precendo CROND[15664]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Aug  2 13:11:01 precendo CROND[15774]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:11:01 precendo CROND[15775]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:11:01 precendo CROND[15776]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:12:01 precendo CROND[15852]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:12:01 precendo CROND[15853]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory
Aug  2 13:12:01 precendo CROND[15854]: (CRON) ERROR chdir failed (/home/asterisk): No such file or directory

This led me to find this post:

I ran this command to add “/home/asterisk”

mkhomedir_helper asterisk

Now my cron log looks better. It includes the schedtc.php as expected.

 tail /var/log/cron       
Aug  2 13:16:01 precendo CROND[16192]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Aug  2 13:16:01 precendo CROND[16193]: (asterisk) CMD ([ -x /var/www/html/admin/modules/dashboard/scheduler.php ] && /var/www/html/admin/modules/dashboard/scheduler.php)
Aug  2 13:16:01 precendo /usr/bin/crontab[16205]: (asterisk) LIST (asterisk)
Aug  2 13:16:02 precendo /usr/bin/crontab[16207]: (asterisk) LIST (asterisk)
Aug  2 13:16:02 precendo /usr/bin/crontab[16208]: (asterisk) REPLACE (asterisk)
Aug  2 13:16:02 precendo /usr/bin/crontab[16210]: (asterisk) LIST (asterisk)
Aug  2 13:16:02 precendo /usr/bin/crontab[16212]: (asterisk) LIST (asterisk)
Aug  2 13:16:02 precendo /usr/bin/crontab[16213]: (asterisk) REPLACE (asterisk)
Aug  2 13:16:02 precendo /usr/bin/crontab[16215]: (asterisk) LIST (asterisk)

I suspect that this will solve the problem as well as some others I may not have noticed.

I went back to the installation guide I followed to see why the home directory was not there.

https://wiki.freepbx.org/display/FOP/Installing+FreePBX+13+on+CentOS+6#InstallingFreePBX13onCentOS6-AddtheAsteriskUser

I saw that the adduser command did have the -m which should have created the directory. But I looked at the history and saw that Andrew had just a few days ago corrected the command from -M to -m. I guess that is what happened.

https://wiki.freepbx.org/pages/diffpagesbyversion.action?pageId=61800790&selectedPageVersions=20&selectedPageVersions=19

@jlarge Did you also build your system from source and not the ISO distro?

It happened again this morning. It was fixed by an inbound call before I could run the command. Sorry for the unformatted post, having some issues with that.

I think my issue is different than np_pyro’s. My system does have an ‘/home/asterisk’ directory however it is empty. If I run the ‘crontab -l -u asterisk | grep schedtc’ no results are returned.

If I remove the grep and just eyeball it there are 15 lines and I don’t see anything similar in there.

If I review the /var/log/cron, I do see the command being ran, ‘Aug 11 08:43:01 cog-voip-01 CROND[18250]: (asterisk) CMD ([ -x /var/www/html/admin/modules/dashboard/scheduler.php ] && /var/www/html/admin/modules/dashboard/scheduler.php)’ including the version I have that is manually running the ‘/var/lib/asterisk/bin/schedtc.php --debug’ every 5 minutes.

If I grep those logs though for schedtc though, ‘grep schedtc /var/log/cron’ the results stop a few days ago.

I did not compile from source. It is a very old freepbx distro installed from iso that has been through a large number of updates. I am running:
*PBX Firmware: 10.13.66-20
*Asterisk: 11
*Framework: 13.0.192.9

The issue occurred again this morning and the user reporting it said it happens every day. I’m not sure that’s true, but possibly every day recently based on what I am seeing in the logs. If I run through ‘grep schedtc /var/log/cron*’ the last time I see it run is on Aug 9, which is the same as it was from my post on Aug 11. It looks like once the issue starts, it won’t resolve until I manually run the command.

The questions I’d like to see answered are:

  1. Is crond failing? If the cron program is stopping, your cron jobs will not run.
  2. check the existence and permissions on the file /var/www/html/admin/modules/dashboard/scheduler.php to make sure it is executable and exists. If it’s executable, it probably exists, so …

As a “bandaid” fix, I’d start watching crond to make sure it is running all the time.

2 Likes

Hate to drag up an old thread but am running 13.0.31.11 Time Conditions and seem to be seeing the exact same issue as described. The BLF/Hints seem to work for a random period of time and then just stop working. Honestly it’s probably been going on since the original post was made but we’ve just started using time conditions again within the past couple of months, so nobody had BLF’s defined.

Started running through some of the troubleshooting above and could swear that asterisk’s crontab did not have the schedtc line in it when I first checked. Then I noticed that there were again cron entries popping up in the log and when I looked sure enough the schedtc entry was in asterisk’s crontab. No way to tell if it was my imagination or not since asterisk’s crontab seems to be updated once a minute. Will definitely be checking for that first next time it stops working.

Blockquote
Oct 20 04:56:01 fpbx01 CROND[16483]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 20 04:57:01 fpbx01 CROND[16564]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 20 04:58:01 fpbx01 CROND[16653]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 20 04:59:01 fpbx01 CROND[16754]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 20 05:00:01 fpbx01 CROND[16843]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 22 12:41:01 fpbx01 CROND[7175]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 22 12:42:01 fpbx01 CROND[7289]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 22 12:43:01 fpbx01 CROND[7437]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 22 12:44:01 fpbx01 CROND[7528]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)
Oct 22 12:45:01 fpbx01 CROND[7627]: (asterisk) CMD ([ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php)

You can see it just stopped after the 5:00 entry on Oct 20th and started again at 12:41 today.

Thoughts?

Just happened again, exactly as before. System is now running 3.1.34.11 Time Conditions

Time Conditions BLFs were not working, checked asterisk’s crontab and the schedtc line was NOT there.

Ran /var/lib/asterisk/bin/schedtc.php --debug

The Time Condition BLFs immediately updated and started working, and asterisk’s crontab once again contained the schedtc line.

Mike

I’ve tried to reproduce this several different ways and have been unable to. Please ensure the setting of: fwconsole setting TCMAINT

This is not a valid version of timeconditions.

Another occurrence, left it since Friday to settle itself, it did not. Sorry, typo before, Time Conditions 3.0.34.11

> [root@fpbx01 ~]# fwconsole setting TCMAINT
> Setting of "TCMAINT" is (bool)[true]

> [root@fpbx01 ~]# crontab -l -u asterisk | grep schedtc

> [root@fpbx01 ~]# /var/lib/asterisk/bin/schedtc.php --debug
> Time Now:11:53|Mon|26|Nov|America/Edmonton
> 
> ==Working with TimeCondition:IUL Open/Closed==
> INVERTED BLF: false (NOT_INUSE = NOT_INUSE & INUSE = INUSE)
> OVERRIDE MODE: not set
> =>08:00-17:00|mon-fri|*|* is now
> TIME MATCHED: True (NOT_INUSE)
> BLF MODE: True (NOT_INUSE)
> Privilege: Command
> Changing TC8 to NOT_INUSE

> [root@fpbx01 ~]# crontab -l -u asterisk | grep schedtc
> * * * * * [ -x /var/lib/asterisk/bin/schedtc.php ] && /var/lib/asterisk/bin/schedtc.php

Again not a valid version of Time Conditions.

 Time Conditions 13.0.34.11 Stable Sangoma Technologies Corporation GPLv3+ Enabled