I have php script running as a cron job, extensively using third party code. Script itself has a few thousands LOC. Basically it\'s the data import / treatment script. (JSON to
Use strace
to see what the program is basically doing from the system perspective. Is it hanging in IO operations etc.? strace
should be the first thing you try when encountering performance problems with whatever kind of Linux application. Nobody can hide from it! ;)
If you should find out that the program hangs in network related calls like connect
, readfrom
and friends, meaning the network communication does hang at some point while connecting or waiting for responses than you can use tcpdump
to analyze this.
Using the above methods you should be able to find out most common performance problems. Note that you can even attach to a running task with strace
using -p PID
.
If the above methods doesn't help, I would profile the script using xdebug. You can analyse the profiler output using tools like KCachegrind