TIPS Cron Jobs

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
Hi I am trying to get a Cron job to run everyday to restart asterisk
I have set a cron job to run am portal restart every day at midnight but it fails to run on it's own, if I run the job manually it's fine... Cron is running and I can't see why it's falling...
 

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
amportal restart, it runs manually i.e. if I set a cron job for it and say "run Now"
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
That's not the proper syntax for a cron job. Look in /etc/crontab for examples.
 

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
But it runs, I've not added it to cron tab I put it in scheduled cron jobs in webmin
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
Are you using full path to amportal? /usr/local/sbin/amportal
 

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
If you hit the save and run now button it runs fine and you see the output
 

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
The environment inside webmin is not the same as cron.

Try what @wardmundy suggests instead of debating it. 99.999999% sure he is right.
 

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
Not sure what he is suggesting, I'm using the cron plugin in webmin, in there there are PBX Crins as well
 

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
In webmin, enter "/usr/local/sbin/amportal restart" instead of "amportal restart"
 
Last edited:

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
In webmin, enter "/usr/local/sbin/amportal restart" instead of "amportal restart"
So I have set it as the above it ruins manually will see if it runs automatically... thanks...
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
I'm not familiar with what WebMin does under the covers, but here's the deal. For amportal to run successfully, it has to be running with either root or asterisk privileges. If it fails, then you need to set it up under /etc/crontab following the examples in that file.
 

Dave Gray

Guru
Joined
May 22, 2013
Messages
150
Reaction score
60
As a safety measure, cron uses an abbreviated path in its environment when it runs an entry. You always want to use a full path for the command in a cron entry, so as to not go through this mess.

As an exercise, try setting a cron job with something like "env > /tmp/env.txt" to see what the cron'd environment looks like. It's pretty empty. Be aware that anything that you're running, that depends on environment variables will not see them, unless you set them as part of the command.
 

Members online

Forum statistics

Threads
25,815
Messages
167,790
Members
19,246
Latest member
aegodoyr
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top