Mult emals - Cron <[email protected]> [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM

For last few weeks i keep getting multiple emails with above topic.

Body shows:

/bin/sh: -c: line 0: unexpected EOF while looking for matching `)’
/bin/sh: -c: line 1: syntax error: unexpected end of file

Any help appreciated.

2 Likes

badly formatted cron jobs. post both

crontab -l -u asterisk

and

crontab -l -u root

*/15 * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM%30)) && /usr/sbin/fwconsole userman --syncall -q
*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/incron/firewall.firewall
* 3 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
50 4 * * * [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sendemail -q > /dev/null 2>&1
50 5 * * * [ -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

crontab -l -u root did not show anything.

thanks for your help

Badly formatted, we can’t read that , use pastebin.

sorry not familiar with that but will a screen shot work?

i was able to find file and deleted below which is what mult email was reporting.

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

the Linux sh shell which is what cron jobs run under by default does not know about $RANDOM

On a distro install the asterisk user’s shell is bash.

Note this runs all the built in jobs with the built in Job class. Removing this line is not recommended. The lines assume the use of bash

If you want your cron jobs to run in a bash shell you probably should be adding the environmental variable

SHELL=/bin/bash

in the table immediately before cron reads that job, by default cron will use /bin/sh which might be aliased by your OS to bash , then again, maybe not, also be aware that these are not run in a login shell.

Generally sh is preferred as it is ‘light-weight’ when compared to other shells .

Another way is to call the job with /bin/bash -c “everything on that line”, (same result)

I am looking at a distro system where /etc/crontab has SHELL=/bin/bash as the first line.

The asterisk user’s crontab does not have this. Is it inherited from system cron?

OP, are you running Distro? I’m curious what caused your cron job to break.

I believe that jobs in /etc/cron* would so inherit, but not those in

/var/spool/cron/crontabs

(I have been wrong before though :wink: )

Alternative just take out the sleep $
It wouldn’t do any harm to so add the SHELL= though in asterisk’s table

Alternatively just take out the sleep … && bit, it was added to stop hardware like proxmox with many PBI on them all running the cron jobs at the same time. thus likely not needed anymore.

Please update to the latest userman module. There was a typo error in the userman syncall cron job which got fixed into the latest userman module.

thanks

What version would what be? Is it in GA or edge?
This kind of response does not really help anyone know if they have the problem or are past it, or if their problem is unrelated.

1 Like

Upgraded 45min ago, now getting this every 15minutes.

Don’t think it’s fixed

Exactly what is in the body of the emails?

Subject: Cron <[email protected]> [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM

/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'
/bin/sh: -c: line 1: syntax error: unexpected end of file
crontab -u asterisk -l
*/15 * * * * [ -e /etc/asterisk/firewall.enabled ] && touch /var/spool/asterisk/incron/firewall.firewall
@daily /usr/sbin/fwconsole pms mk_dirty > /dev/null 2>&1
@daily [ -x /var/lib/asterisk/bin/freepbx_sipstation_check ] && /var/lib/asterisk/bin/freepbx_sipstation_check 2>&1 > /dev/null
30 23 * * * /usr/sbin/fwconsole backup --backup=ad6d137b-88f1-40be-9490-adb49c8fe440 > /dev/null 2>&1
21 0 * * * /usr/sbin/fwconsole certificates --updateall -q 2>&1 >/dev/null
30 23 * * * /usr/sbin/fwconsole backup --backup=ad6d137b-88f1-40be-9490-adb49c8fe440  > /dev/null 2>&1
* * * * * /usr/sbin/fwconsole queuestats --syncall >> /tmp/reader.log 2>&1
*/15 * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM%30)) && /usr/sbin/fwconsole userman --syncall -q
59 23 * * 0 /var/lib/asterisk/bin/queue_reset_stats.php --id=6001
* 0 * * * /usr/sbin/fwconsole util cleanplaybackcache -q
14 6 * * 6 [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma listonline --sendemail -q > /dev/null 2>&1
14 7 * * 6 [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole sys listonline --sendemail -q > /dev/null 2>&1
14 8 * * 6 [ -e /usr/sbin/fwconsole ] && /usr/sbin/fwconsole ma upgradeall --sendemail -q > /dev/null 2>&1
* * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole job --run --quiet 2>&1 > /dev/null

Which I’ve just changed to:

*/15 * * * * [ -e /usr/sbin/fwconsole ] && sleep $((RANDOM\%30)) && /usr/sbin/fwconsole userman --syncall -q

In the last line $((RANDOM\%30)) is the fail escaping the % in \% is not a good thing. But lets also check the shell that asterisk is using

su  asterisk -c "ls -l $(which sh)"

Ive tried to remove this from cron jobs but just keeps coming back and have emails bounced back every 10 mins also.

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