Hi. I have a script that needs to run from a cron job. I added the script as explained, in the deployment instructions.
crontab -e (root) looks as follows
* * * * * /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1 -z 10.24.0.231 > /dev/null 2>&1 * * * * * /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server2 -z 10.24.0.231 > /dev/null 2>&1
file permissions # ls -asl /usr/bin/ZabbixApacheUpdater.py 12 -rwxr--r-- 1 root root 8740 Mar 11 10:05 /usr/bin/ZabbixApacheUpdater.py
the messages log indicates that it has run
Mar 11 11:47:01 linux-epfq /usr/sbin/cron[18297]: (root) CMD (/usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1 -z 10.24.0.231 > /dev/null 2>&1 ) Mar 11 11:47:01 linux-epfq /usr/sbin/cron[18299]: (root) CMD (/usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server2 -z 10.24.0.231 > /dev/null 2>&1)
But it's not doing anything. When I run the same syntax command from the command line it runs correctly every time.
I have tried changing the fill permissions and the syntax of the cron entries but nothing works.
Any ideas what I have missed ?
Thanks
If it tries to execute something in another dir an this dir doesnt have the right peissions it wont execute Em 10/03/2011 19:53, "Gregory Machin" gdm@linuxpro.co.za escreveu:
Hi. I have a script that needs to run from a cron job. I added the script as explained, in the deployment instructions.
crontab -e (root) looks as follows
- /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1
-z 10.24.0.231 > /dev/null 2>&1
- /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server2
-z 10.24.0.231 > /dev/null 2>&1
file permissions # ls -asl /usr/bin/ZabbixApacheUpdater.py 12 -rwxr--r-- 1 root root 8740 Mar 11 10:05
/usr/bin/ZabbixApacheUpdater.py
the messages log indicates that it has run
Mar 11 11:47:01 linux-epfq /usr/sbin/cron[18297]: (root) CMD (/usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1 -z 10.24.0.231 > /dev/null 2>&1 ) Mar 11 11:47:01 linux-epfq /usr/sbin/cron[18299]: (root) CMD (/usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server2 -z 10.24.0.231 > /dev/null 2>&1)
But it's not doing anything. When I run the same syntax command from the command line it runs correctly every time.
I have tried changing the fill permissions and the syntax of the cron entries but nothing works.
Any ideas what I have missed ?
Thanks
users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
On Thu, Mar 10, 2011 at 5:53 PM, Gregory Machin gdm@linuxpro.co.za wrote:
Hi. I have a script that needs to run from a cron job. I added the script as explained, in the deployment instructions.
crontab -e (root) looks as follows
- /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1
-z 10.24.0.231 > /dev/null 2>&1
- /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server2
-z 10.24.0.231 > /dev/null 2>&1
Try redirecting the output to a file (say, /var/log/zabbixdebug.log) instead of /dev/null. The program may provide some clues about what is going wrong.
But it's not doing anything.
When I run the same syntax command from the command line it runs
correctly every time.
There may be something about your environment that is different from what cron sees, maybe some environmental variable that the script depends upon to find files, or that one of the servers needs. With cron jobs you usually have to specify fully qualified paths for everything, maybe you script is not doing that, then not finding something it needs to do its work.
The vast majority of the time when a cron job fails to work it is one of two things, the environment or permissions.
I have tried changing the fill permissions and the syntax of the cron
entries but nothing works.
As a sanity check, make sure that what you have in the crontab file is still correct, copy it from the crontab file and paste it into a shell prompt to verify that you haven't made matters worse while trying to find the problem.
Mike
On 11Mar2011 11:53, Gregory Machin gdm@linuxpro.co.za wrote: | I have a script that needs to run from a cron job. I added the script | as explained, in the deployment instructions. | | crontab -e (root) looks as follows | | * * * * * /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1 | -z 10.24.0.231 > /dev/null 2>&1
Throwing away all the output is a good way to never find out what is wrong. Try replacing:
/dev/null 2>&1
with:
my-script.output 2>&1
and looking at that file.
[...] | But it's not doing anything.
It is probably failing very early.
| When I run the same syntax command from the command line it runs | correctly every time. | I have tried changing the fill permissions and the syntax of the cron | entries but nothing works. | Any ideas what I have missed ?
Crons environment is very spartan. Your .[bash_]profile etc have not run and so on. Probably an environment variable is missing or too small.
By capturing the output in a file as described you should learn more.
Cheers,
looks like it's related to the environmment variables. thanks for the advise. Will look into howto set the env vars.
On Fri, Mar 11, 2011 at 1:15 PM, Cameron Simpson cs@zip.com.au wrote:
On 11Mar2011 11:53, Gregory Machin gdm@linuxpro.co.za wrote: | I have a script that needs to run from a cron job. I added the script | as explained, in the deployment instructions. | | crontab -e (root) looks as follows | | * * * * * /usr/bin/python /usr/bin/ZabbixApacheUpdater.py -c server1 | -z 10.24.0.231 > /dev/null 2>&1
Throwing away all the output is a good way to never find out what is wrong. Try replacing:
> /dev/null 2>&1
with:
>> my-script.output 2>&1
and looking at that file.
[...] | But it's not doing anything.
It is probably failing very early.
| When I run the same syntax command from the command line it runs | correctly every time. | I have tried changing the fill permissions and the syntax of the cron | entries but nothing works. | Any ideas what I have missed ?
Crons environment is very spartan. Your .[bash_]profile etc have not run and so on. Probably an environment variable is missing or too small.
By capturing the output in a file as described you should learn more.
Cheers,
Cameron Simpson cs@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/
There are only two types of ships in the NAVY; SUBMARINES and TARGETS !!! - Richard Pierson