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...
 
amportal restart, it runs manually i.e. if I set a cron job for it and say "run Now"
 
That's not the proper syntax for a cron job. Look in /etc/crontab for examples.
 
But it runs, I've not added it to cron tab I put it in scheduled cron jobs in webmin
 
Are you using full path to amportal? /usr/local/sbin/amportal
 
If you hit the save and run now button it runs fine and you see the output
 
The environment inside webmin is not the same as cron.

Try what @wardmundy suggests instead of debating it. 99.999999% sure he is right.
 
Not sure what he is suggesting, I'm using the cron plugin in webmin, in there there are PBX Crins as well
 
In webmin, enter "/usr/local/sbin/amportal restart" instead of "amportal restart"
 
Last edited:
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...
 
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.
 
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
26,688
Messages
174,412
Members
20,259
Latest member
Fadeek86
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.
Back
Top