Process time-to-live setting

I have a cron job scheduled to run every 5 mins, and run a php script.
Something was not right about the script and when I checked the server had very little spare memory.
Looked in running processes and I could see that many instances of the script were still running.
I am new to this whole linux admin thing, and I am using webmin. I have a few questions.
For each instance of this script there are three lines:

  [15339](https://server31008.uk2net.com:10000/proc/edit_proc.cgi?15339) root 15:36 CROND            [15340](https://server31008.uk2net.com:10000/proc/edit_proc.cgi?15340) root 15:36 php /var/www/html/beta/assets_30.php            [15344](https://server31008.uk2net.com:10000/proc/edit_proc.cgi?15344) smmsp 15:36 /usr/sbin/sendmail -FCronDaemon -i -odi -oem -oi -t

First, is there a diference between 'kill' and 'terminate' ?
How can I kill/term all three at once, since they are obviosly related? I am currently killing only the php script, (ok after getting rid of all the php entries all the sendmail ones dissapeared. ).
Why is there a sendmail process associated with the cron job (this job has nothing to do with sending mail)

Is there a way I can set a time-to-live on each script so that linux can kill the processes automatically in case they stall.

The Bulletin board munged your question. Could you repost the cron line please? When posting, click on "Go Advanced" and under Additional Options, uncheck "Automatically parse links in text" and also wrap it in "code" tags.

A few comments:

  • sendmail -t should terminate when the parent is terminated.
  • You can set a "timeout" but its based on cpu usage, not wall-clock time. See "ulimit -a".
  • Inside a PHP script you can call pcntl_alarm(30); to end the script after 30 seconds. (For more on what you can do with this, see PHP - Alarm functions - LXF Wiki .)