I'm using python 2.4 running on Fedora Core 4. I have written a python
program called ipscan.py that checks the external ip address of my
cable internet connection, and on change, will update the dns records
at my dns provider, zoneedit. So basically, I've setup dynamic dns
using python. Once the ip compare and/or update is complete, I log the
results to a text file called update.log. When I run the program in a
bash shell with the command "python ipscan.py", the program runs fine
and the results are appended to update.log. When I run this program as
a cron job under the root user with the previously mentioned command,
the program runs without errors but does not append an entry to the
log. The permissions on the update.log file should not be an issue
since I'm running the cron job as root, but I've given root write
permissions just to be safe. What would cause the logging to work at a
command prompt but fail in cron? I'm not getting any errors in the
cron logs or /var/spool/mail/root.
Thanks for your assitance. 4 2997
On 23 Nov 2005 16:23:11 -0800, vagrantbrad wrote I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the dns records at my dns provider, zoneedit. So basically, I've setup dynamic dns using python. Once the ip compare and/or update is complete, I log the results to a text file called update.log. When I run the program in a bash shell with the command "python ipscan.py", the program runs fine and the results are appended to update.log. When I run this program as a cron job under the root user with the previously mentioned command, the program runs without errors but does not append an entry to the log. The permissions on the update.log file should not be an issue since I'm running the cron job as root, but I've given root write permissions just to be safe. What would cause the logging to work at a command prompt but fail in cron? I'm not getting any errors in the cron logs or /var/spool/mail/root.
You're not giving us much detail about your script, so we can only guess. My
guess is that your python script is either not invoked at all or it dies
(raises an exception) before appending to the update.log.
You should keep in mind that cron jobs don't run in a normal login shell,
don't have the normal environment variables, and are not attached to a tty.
Any of those factors can conceivably cause a script to fail under cron when it
works fine from a shell.
HTH,
Carsten.
Carsten Haese wrote: On 23 Nov 2005 16:23:11 -0800, vagrantbrad wrote
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the dns records at my dns provider, zoneedit. So basically, I've setup dynamic dns using python. Once the ip compare and/or update is complete, I log the results to a text file called update.log. When I run the program in a bash shell with the command "python ipscan.py", the program runs fine and the results are appended to update.log. When I run this program as a cron job under the root user with the previously mentioned command, the program runs without errors but does not append an entry to the log. The permissions on the update.log file should not be an issue since I'm running the cron job as root, but I've given root write permissions just to be safe. What would cause the logging to work at a command prompt but fail in cron? I'm not getting any errors in the cron logs or /var/spool/mail/root.
You're not giving us much detail about your script, so we can only guess. My guess is that your python script is either not invoked at all or it dies (raises an exception) before appending to the update.log.
You should keep in mind that cron jobs don't run in a normal login shell, don't have the normal environment variables, and are not attached to a tty. Any of those factors can conceivably cause a script to fail under cron when it works fine from a shell.
Since we're guessing, *my* guess would be that the cron-triggered runs
are running in some directory other than the one the manually-triggered
jobs are, and that there is a separate update.log file in that directory.
The fix, of course, would be to use an absolute path to identify the log
file (if I'm right).
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/
<va*********@yahoo.com> skrev i en meddelelse
news:11**********************@o13g2000cwo.googlegr oups.com... permissions just to be safe. What would cause the logging to work at a command prompt but fail in cron?
Because the environment is different; "man cron" might tell *how* it is
different (I cannot because it varies with platform, distribution ... )
You were right!! I had a relative path to the update.log file, so I
looked in the home path of the cron environment and found the
update.log file that the cron job was writing to. I updated my program
to point to the absolute path of the update.log file that I wanted the
logs written to, and now it works.
Thanks,
Brad
Steve Holden wrote: Carsten Haese wrote: On 23 Nov 2005 16:23:11 -0800, vagrantbrad wrote
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the dns records at my dns provider, zoneedit. So basically, I've setup dynamic dns using python. Once the ip compare and/or update is complete, I log the results to a text file called update.log. When I run the program in a bash shell with the command "python ipscan.py", the program runs fine and the results are appended to update.log. When I run this program as a cron job under the root user with the previously mentioned command, the program runs without errors but does not append an entry to the log. The permissions on the update.log file should not be an issue since I'm running the cron job as root, but I've given root write permissions just to be safe. What would cause the logging to work at a command prompt but fail in cron? I'm not getting any errors in the cron logs or /var/spool/mail/root.
You're not giving us much detail about your script, so we can only guess. My guess is that your python script is either not invoked at all or it dies (raises an exception) before appending to the update.log.
You should keep in mind that cron jobs don't run in a normal login shell, don't have the normal environment variables, and are not attached to a tty. Any of those factors can conceivably cause a script to fail under cron when it works fine from a shell. Since we're guessing, *my* guess would be that the cron-triggered runs are running in some directory other than the one the manually-triggered jobs are, and that there is a separate update.log file in that directory.
The fix, of course, would be to use an absolute path to identify the log file (if I'm right).
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: KeOu |
last post by:
Hi,
We are running a application on the Linux, and would like to have a web
interface to restart it remotely using PHP. I would like to get an
advice on how to do it.
Thanks.
KeOu
|
by: Eric |
last post by:
I'm trying to have some scripts run periodically on Windows XP and found the "Task Scheduler" did not execute my scripts. My scripts are of the form scriptName.py, and will run just by invoking that...
|
by: George |
last post by:
Hi,
Does anyone have any experience with GnuPGInterface? I'm having a
problem with decrypting files through a cron job. The below job works
great when I run it manually from the command line, but...
|
by: erikcw |
last post by:
Hi all,
When trying to run this python script from cron, I get the following
error:
Traceback (most recent call last):
File "/home/lybp/public_html/wa/wa.py", line 14, in ?
import MySQLdb...
|
by: uzzi |
last post by:
I don't know how to make a php script to work via cron...I want to make it run daily...My server API is CGI/Fast CGI.I have hosting from godaddy and in the help section i found that i have to specify...
|
by: Phil |
last post by:
I have a php script that queries some Oracle DB and outputs a single
line of plain text with <brat the end for each query. This is
Apache2, php4.4.8 and Oracle Instant Client 10.1.0.5 all on CentOS...
|
by: Stephen Cattaneo |
last post by:
Hello all,
I am attempting to execute an automated test (written in Python) via
cron. I have to check the HOSTNAME variable as part of the test, oddly
under cron the HOSTNAME environment...
|
by: Cameron Simpson |
last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote:
Because $HOSTNAME is a bash specific variable, set by bash but NOT
EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
|
by: Sam |
last post by:
I have a program which works great when run from the command line.
But when I run it combined with something else such as:
- piping it through less
- cron
- execl (i.e. calling it from another...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |