Mult emals - Cron <asterisk@24408486> [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM

Using WinSCP I can see the relevant entry (the last line) in file /var/spool/cron/asterisk so I can delete it.

Would not then a rollback be adequate?

That would take some regression testing, ask FreePBX but they are currently not exactly A+ on that right now. Why not suck it and see. let us know how it worked out.

I’m happy to try but don’t know how to roll it back.

Since it seems the entire Sangoma team doesn’t care about anything outside of M-F 8-5…

I upgraded one of my PBX systems last night. I was not having any issues prior to the upgrade.

'userman' from 16.0.25.18 to 16.0.25.28

Now I have the 15 minute cron error.

[jbusch@pbx ~]$ sudo -u asterisk crontab -l
[sudo] password for jbusch: 

*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/incron/firewall.firewall
*/15 * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole userman --syncall -q
* 3 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
9 19 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sendemail -q > /dev/null 2>&1
9 20 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole sys listonline --sendemail -q > /dev/null 2>&1
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null

I checked edge, and there was an update to .29

| userman             | 16.0.25.28 | Online upgrade available (16.0.25.29)     | AGPLv3+     |
sudo fwconsole ma upgrade userman --edge
sudo fwconsole reload

And still a screwed up crontab.

*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/incron/firewall.firewall
*/15 * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole userman --syncall -q
* 4 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
47 17 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sendemail -q > /dev/null 2>&1
47 18 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole sys listonline --sendemail -q > /dev/null 2>&1
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null

Here are the known rollback options for FreePBX 16. I’ll start with .18 as that is where I came from.
image

sudo fwconsole ma downloadinstall userman --tag=16.0.25.18
sudo fwconsole reload

It removed the userman cron line.

[jbusch@pbx ~]$ sudo -u asterisk crontab -l

*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/incron/firewall.firewall
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null
* 2 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
36 19 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sendemail -q > /dev/null 2>&1
36 20 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole sys listonline --sendemail -q > /dev/null 2>&1

My last failure was at 6:15PM. It is now 6:24PM. I’ll know in a few minutes.
image

I am on 15: Upgrading module ‘userman’ from 15.0.63 to 15.0.65

The FreePBX docs say ‘Starting in version 12 you can downgrade module versions from Modue Admin.’ but my V15 Module Admin does not show a ‘Previous’ option.

You have to click check online before that becomes visible.

Not really surprised, it still comes in.
image

On a FreePBX distro

ls -l $(cat /etc/shells) 

revealing that /bin/sh is an alias of /bin/bash , from a bash shell try

bash --version
echo $((RANDOM\%30))
echo $((RANDOM%30)) 
echo $((${RANDOM} % 30)) 

Now the second and the third should work fine , the third one would be what I would use for clarity, as the $(( )) does the math so ${RANDOM} is ‘modulo’ed’ 30. But is there any way that unnecessarily ‘escaping’ the modulus operator in the first on will ever get to performing the operation after && ?

Thank you - worked.

On CRON jobs list this time there were actually two similar jobs: one running every minute and the other every 15. I deleted both.

It is a couple of hours later and there have been no messages and the two Cron lines I deleted have not come back.

All seems to be OK.

probably a mistake to not run /usr/sbin/fwconsole job --run regularly, read why above in this thread.

Thank you. I assumed whatever needs to be there would be put back automatically (I don’t remember seeing the minute-timer version originally but could well be wrong).

I have an other system running and that has not been upgraded - still on 15.0.63

So I have copied back the cron line from there.

* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null

https://issues.freepbx.org/browse/FREEPBX-23162

I’ve just gone thru the process on a 15 system to determine how one might roll back to the most recent version without the crontab issue. There is a lot in this thread, and it’s possible this may have already been shared.

Starting with the current stable 15 version, you can see the problem line is here:

# grep RANDOM /var/www/html/admin/modules/userman/Userman.class.php
            $freepbxCron->addLine("*/15 * * * * [ -e ".$AMPSBIN."/fwconsole ] && sleep $((RANDOM%30)) && ".$AMPSBIN."/fwconsole userman --syncall -q");

I downgrade to 15.0.63 using this command:

# fwconsole ma downloadinstall userman --tag 15.0.63
# fwconsole r

And once that’s downloaded, I can confirm the problem line is not present in the userman module code:

# grep RANDOM /var/www/html/admin/modules/userman/Userman.class.php
<< null >>

However, the crontab entry remains, and the fwconsole job is not present as expected:

# fwconsole job --list | grep userman
# crontab -l -uasterisk | grep userman
    */15 * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM%30)) && /usr/sbin/fwconsole userman --syncall -q

At this point reinstalling the module fixes those tasks:

# fwconsole ma install userman

Which we can confirm with:

# crontab -l -uasterisk | grep userman
# fwconsole job --list | grep userman
    | 45 | userman              | syncall                | */15 * * * * | 2021-12-19 13:15:00 | Class: FreePBX\modules\Userman\Job                                                                                                     | Yes     

Now chown (prob not necessary) and reload:

# fwconsole chown
# fwconsole r

[FREEPBX-23162] userman 15.0.65 creates bad crontab entry - Sangoma Issue Tracker

1 Like

@lgaetz WTF with @kgupta closing the original report, not to mention the one with detail, in favor of the follow on report with no details that jsut linked to this thread?

https://issues.freepbx.org/browse/FREEPBX-23162

https://issues.freepbx.org/browse/FREEPBX-23167

I found the conversation about not using cron in the first place very enlightening. So beyond a stupid syntax fix, will this get reverted and fixed properly?

Hi @sorvani

If you can see [FREEPBX-23167] Cron job generates nuisance emails - Sangoma Issue Tracker got closed as a duplicate of [FREEPBX-23167] Cron job generates nuisance emails - Sangoma Issue Tracker. The same i have updated to reporter also.

Also, userman v15.0.66 has been pushed with the fix.

Reporter of [FREEPBX-23162] userman 15.0.65 creates bad crontab entry - Sangoma Issue Tracker confirmed issue fixed on userman v15.0.66 .
Request you to please give try with userman vv15.0.66 and update the [FREEPBX-23167] Cron job generates nuisance emails - Sangoma Issue Tracker (keeping this jira for tracking this issue).

also just fyi - QA is working on to validate the fix so feel free to update the Jira if you find any issue. will keep you posted the fix version as soon as QA confirmed the fix.

thanks

Would that be the same ‘QA’ that approved the broken one :wink: ?

2 Likes

Yes, because they didn’t fix 16. Even though @kgupta marked the original ticket closed and @lgaetz’s ticket as resolved.

Still marked closed incorrectly as a duplicate when it is not.

Marked resolved when it is not.

1 Like

Marked minor, when the volume of forum traffic indicates it is not!

I’m getting the same error. FreePBX distro install – updated to the latest version.

A few hours ago, I received an email that an update is available for the “User Management” module. Updated it to the latest version - 15.0.66

But I still continue to get the email with cron error.

I tried manually editing this line in
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null

to

* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null

but my changes get automatically undone. I guess there is another FreePBX process that is at play here.

Has anyone managed to fix this issue?

Thanks