I launch one Python script out of another one on an Amazon EC2 Ubuntu instance using a command:
os.system(call)
where call
has the form
"./script2.py arg1 arg2 arg3"
I've noticed that from time to time script2.py
somehow terminates prematurely. I have some logging statements in it but they don't show what's going on. So my questions are:
- I read that
system()
returns some sort of exit status. What's the best test to distinguish between a normal and abnormal termination? That is, I only want to produce a log message inside the calling script if there is some sort of abnormal termination. - Is there any sort of system log where I could try to find traces of terminated processes?
Assuming that your child script does not use standard output for something and returns non-zero on a crash (this should be default for
python
executable though):1> os.system returns the system code if it returns 0 process ran and terminated successfully but if it returns any number then generally it means an error but it depeds on how progam responds to the errors what i mean is if progam returns 1 on success os.system will return 1
for example
2> python provides syslog module you can try it like
syslog is a buil-in unix api provided by the os itself
http://docs.python.org/2/library/syslog.html