How can i submit and apply changes to FreePBX Chronologically

as the title suggest i wish to do a timed submit and apply on FreePBX’s side is this possible if so how.

At the CLI, you can do a submit and reload with:

amportal a r

You could schedule this with a cron.

thank you very much for your help this has solved my issue.

1 Like

hi sorry to bring up this old thread.
i have been trying to make cron job, however it seems to not work.
the file permissions are set to read, write and execute for all.
i get 2 errors this one
/root/freepbxcron.sh: 2: /root/freepbxcron.sh: wall
: not found
/root/freepbxcron.sh: 4: /root/freepbxcron.sh: Syntax error: Bad fd number

and this one

/root/freepbxcron.sh: 2: /root/freepbxcron.sh: wall
: not found
/root/freepbxcron.sh: 3: /root/freepbxcron.sh: amportal: not found

could some one please shed some light on what i am doing wrong.
thanks

Can you post the script here?

Some issues (like, ‘command’ not found) can be solved by including full calling path

(so, on the ssh/telnet cmd line do ‘which amportal’ and then substitute the ‘amportal’ call with
one including path)
this is what it says on mine

[root@pbx ~]# which amportal
/usr/local/sbin/amportal
[root@pbx ~]# which wall
/usr/bin/wall

(or in more baroque fashion,
include this in the cron script at its start:

amportalcmd=`/usr/bin/which amportal`
wallcmd=`/usr/bin/which wall`

and then use $amportalcmd and $wallcmd instead of straight amportal or wall
throughout the script.
ah and do include #!/bin/bash as the very first line of the script
HTH

#!/bin/bash
echo Starting PHP script | wall
php -f /var/www/html/extensioninput.php 2>&1
echo Granting asterisk WRITE permissions on /var/lib/asterisk/bin/ | wall
chown -R asterisk:asterisk /var/lib/asterisk/bin/amportal
echo Reloading FreePBX | wall
amportal a r

this is what i am using (i do know very little about bash and .sh files)

Try this then

#!/bin/bash
amportalcmd=`/usr/bin/which amportal`
wallcmd=`/usr/bin/which wall`
phpcmd=`/usr/bin/which php`
chowncmd=`/usr/bin/which chown`
echo Starting PHP script | $wallcmd
$phpcmd -f /var/www/html/extensioninput.php 2>&1
echo Granting asterisk WRITE permissions on /var/lib/asterisk/bin/ | $wallcmd
$chowncmd -R asterisk:asterisk /var/lib/asterisk/bin/amportal
echo Reloading FreePBX | $wallcmd
$amportalcmd a r

Reason is, cron scripts usually run with limted environment variables, including not having all the PATH available that ‘normal’ console sessions do.
In case the above is messed up and the $command way doesn’t work, just call which with the 4 commands you’re using (chown, php, amportal and wall) on the command line interactively, and then precede the straight calls in the script with the full paths it gives you.
HTH

just tried it it gave out an error :

/bin/sh: 1: /root/freepbxcron.sh: not found

though it did take off most of the errors :smiley:

hmm…
what does the command line say, if you give it

which bash

interactively ?
(the console, not the asterisk command line)

/bin/bash

is the one it gives me

hmm…
that error is what cron puts into logs? Or where do you see that error coming on?
(i mean, do you run this script manually and see this error?)

Does the script work when called from cron, beside of giving this error?

i am using webmin, so i run the script through webmin by pressing run now.
that is the output webmin gives me

i am also logged in as root VIA SSH and see no output when i run

mmm… not familiar with webmin, sorry… but check, what name of script is cron calling exactly (maybe typo?) Other than that, not sure. Maybe try crontab -e from console without webmin ?

webmin is just a GUI based browser for file transfers and few oteher bits like cron jobs

still thank you your help was appreciated i can run an asterisk reload command but this one doesnt want to

i have solved this issue your code was perfect, thank you.

i was writing and saving the .sh in notepad++ turns out that linux see’s that as DOS format.
best thing to do is open up VI or NANO and write and save in there and a .sh

Notepad++ will do what you want. When working in windows the very first rule of editing files for *nix is to enable “show all characters” and force the EOL to “Unix/OSX” style in Notepadd++.

thank you, for that advice is noted :slight_smile: how ever i said the script works it does.
but does not launch the amportal a r ,it says command amportal a is unreconized