I have been running a service (a python script using twistd library) as a non-root user that stays in the background. I've been noticing that it crashes at random times and I want to understand why. As far as I know it doesn't use any specific log file on its own, so can you tell me where I can get more information about what's going on? Either a program/application/event log file or a python-related one?
Asked
Active
Viewed 1.5k times
0
-
I'm not a programmer, but could `strace` help? – petrus Dec 31 '11 at 13:49
-
How do you know it is crashing? You can have a look at system logs `/var/log/messages` and `/var/log/syslog`. – Khaled Dec 31 '11 at 13:49
-
@Khaled I have the same script running on two systems, in one of them the script is always there (`ps x`) after I executed it once, in the other is not. I've been starting it again and again, it seems to run for some hours every time but next day when I login to the system to check it's not there anymore. – Ion Dec 31 '11 at 14:02
-
@Khaled I've searched the log files you mentioned but I haven't encountered anything related to the specific script... – Ion Dec 31 '11 at 14:18
-
It is a good idea to follow @S19N answer and try to run the script by redirecting output and error to a log file and see it after every while. – Khaled Dec 31 '11 at 15:43
3 Answers
4
If the script does not record any log by itself, this can be accomplished by redirecting standard output and error to a known file at launch. In bash use
script.py > /var/log/script.log 2>&1
The nohup
utility or shell builtin may also help.
S19N
- 1,693
- 1
- 17
- 28
0
I suspect that it is crashing due to an uncaught Exception somewhere. Try catching and logging the exceptions at the highest level in the script that you can. It may give you some clues.
Stuart Woodward
- 1,343
- 4
- 14
- 29